Search code examples
sharepointmicrosoft-teamspower-automate

How to use Power Automate to set the expiry of Teams videos stored in Sharepoint?


I want to automatically remove any expiration date associated with Teams videos stored in a Sharepoint folder using Power Automate. In order to do this I have:

  1. Created a listener for new files created in a Sharepoint folder - using "When file is created (properties only)".

  2. This is where I am stuck - I am unable to find an action that allows me to update the expiration date. I have found:

  • Update file properties => however, when I select Site Address/Library Name, it only gives me the option to update "Image Tags", "Title", "Description", etc. but not the expiration.

I also looked at calling the Sharepoint API directly but wasn't able to find an example of an appropriate API call to make.


Solution

  • You can use a POST request with the SetExpirationDate method. Below is an example of that approach.

    URI

    _api/web/GetFileByServerRelativeUrl('/sites/YourSite/@{triggerOutputs()?['body/{FullPath}']}')/SetExpirationDate
    

    Body Payload

    {
    "expirationDate":"2023-10-24T09:10:12.000Z"
    }
    

    enter image description here

    enter image description here

    enter image description here