Hello,
I am new to the Rest API, so maybe it's just a beginners mistake. I am able to create new objects, change group members, etc. but I have not been able to figure out how to use endpoints that require lists in the form data. For example, if I create a folder and want to add a custom permission, I get the following errors:
## Get ticket 
$Cred = Get-Credential
$Body = @{
username = $Cred.UserName
password = $Cred.GetNetworkCredential().Password
}
$BaseUrl = 'https://blabla.bla.de/cs/llisapi.dll/api/'
$Url = $BaseUrl + 'v1/auth'
$ticket = Invoke-RestMethod -Method 'Post' -Uri $Url -Credential $Cred -Body $Body -ContentType 'application/x-www-form-urlencoded' -SessionVariable OTSesh
# Create authentication header 
$Headers = @{
otcsticket = $ticket.ticket.ToString()
}
# Create new folder - works fine 
$Body = @{
type = 0
parent_id = 105119060
name = 'Test'
}
$Url = $BaseUrl + 'v2/nodes'
$newFolder = Invoke-RestMethod -Method 'Post' -Uri $Url -Credential $Cred -Headers $Headers -Body $Body -ContentType 'application/x-www-form-urlencoded' -SessionVariable OTSesh
# Add custom permission - fails 
$Url = $BaseUrl + 'v2/nodes/{0}/permissions/custom' -f $newFolder.results.data.properties.id
$Body = @{
'right_id' = 11371;
'permissions' = 'see', 'see_contents'
}
Invoke-RestMethod -Method 'Post' -Uri $Url -Credential $Cred -Headers $Headers -Body $Body -ContentType 'application/x-www-form-urlencoded' -SessionVariable OTSesh
-> This one (above) results in: error: one or more parameters are invalid
$jsonBody = $Body | ConvertTo-Json
Invoke-RestMethod -Method 'Post' -Uri $Url -Credential $Cred -Headers $Headers -Body $jsonBody -ContentType 'application/json' -SessionVariable OTSesh
-> using json above, I get: error: required parameter permissions missing
Might this be a powershell thing or am I using the parameters in a wrong way?