Set 'ExpirationsDays' on a Folder using Sharefile REST API

  • 1
  • Question
  • Updated 3 weeks ago
  • (Edited)

We currently have a working solution (script) for creating ShareFile folders using the ShareFile API, and now need to set the property ‘ExpirationDays’ on new folders that we create. And here is where I struggle and would anyone's help/input.

 When I run below code, the folder will be created with a value of “-1” for ExpirationDays, despite me specifying “10” as a value. So I figured this is due a bug in the API code, so next solution I tried was to do a PATCH on the folder instead to change the value, but that only gives me ‘MethodNotAllowed’ error.

Is it not possible to specify ExpirationDays when creating a folder?
Is my synytax incorrect regarding the PATCH command?

Write-Host "Creating new Shared Folder.."
$newFolder = New-Object ShareFile.Api.Models.Folder
$newFolder.ExpirationDays = 10
$newFolder.Name = $clientNameSpecified
$newFolder.Description = "Folder for users related to $clientNameSpecified" $newFolder | Format-List *

$createdFolder = Send-SfRequest -Client $sfClient -Entity Items -Method POST -Navigation Folder -Body $newFolder

$createdFolder | Format-List * Write-Host "Done creating new Shared Folder!" #Despite above the folder will be created with a value of -1 on property ExpirationDays

 #Trying to change value using PATCH, but gives “MethodNotAllowed”..

Write-Host "Changing ExpirationDays.."
$createdFolderID = $($
$requestJSON = '[ { "ExpirationsDays":"10" }]' $requestJSON
$createdFolderPatched2 = Send-SfRequest -Client $sfClient -Entity Items -Method PATCH -Id $createdFolderID -Navigation Folder -BodyText $requestJSON
$createdFolderPatched2 | Format-List *

Images showing output of above:
Photo of rasmus.kindberg


  • 1 Post
  • 0 Reply Likes

Posted 3 weeks ago

  • 1
Photo of Pratik Somanagoudar

Pratik Somanagoudar, Software Engineer

  • 25 Posts
  • 2 Reply Likes
Hi Ramus,

I saw your request, and looking at the content you provided to the endpoint it seems like you are passing a List of Folder rathar than a folder in the JSON body for the endpoint. Request you to kindly check the input and let me know if you feel things are correct 
Also, I noticed that you are using .com domain instead of .eu (some calls on the account that we noticed) for this account that is supposed to be in EU. There would not be any significant differences but calling the .eu domain my give you better performance.