API to create shares working except permissions

Hi,

I’ve tried with postman and also writing out from scratch in powershell but cant get the last thing I need to work. I can create shares, set password, set type, but nothing I do will set the permission. Is the post argument really ‘permissions’? Anyone have this working?

Powershell code below, note this works, I get a 200 and the share is created with everything EXCEPT the right permissions which default to 1 (I need 15). I can then get the details with another call, update (everything except the permission) and I can see and use the share in the gui. Except I can’t upload anything as I need to.

I have created the same arguments in postman (tool to test api calls) and it has same results, i.e. it all works except I cant set the permissions of the share. Again I tried creating with defaults and updating after, but still no luck with the permissions.

Note, requirement as we need to collaborate with 500 customers on a project so I need 500 shares and the staff WILL mess it up if I leave it to them, hence wanting to make them automatically.

$username = “user”
$password = “pass”
$URL = “https://domain/ocs/v1.php/apps/files_sharing/api/v1/shares
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

$headers = @{}
$headers[“OCS-APIRequest”] = “true”
$headers[“Authorization”]=(“Basic {0}” -f $base64AuthInfo)

$body = @{}
$body[“path”] = “/Photos”
$body[“shareType”] = 3
$body[“password”] = “hOPllo!!!23987*$”
$body[“permissions”] = 15 #not working!!

[xml]$xmlCreatedShare = Invoke-WebRequest -Credential $Auth -Headers $headers -Method POST -URI $URL -Body $body

$xmlCreatedShare.ocs.data.url
$xmlCreatedShare.ocs.data.path
$xmlCreatedShare.ocs.data.permissions

Hi there, have you solved this??

I have found that if you change the “shareType” to 1 or 0 not the public one, then the permissions are save or at least in some part, because the numeric code saved change don’t know why.

by example sharing with the group:

$body = @{}
$body["path"] = "/test.txt"
$body["shareType"] = 1
$body["shareWith"] = "admin"
$body["password"] = “hOPllo!!!23987*$”
$body["permissions"] = 2 #not working!!

with $xmlCreatedShare.ocs.data.permissions i get:

3