Skip to content

Additional Examples

On this page we'll add additional samples on how to use REST API.

Get all delegations created by a user

# Get delegator profile id using email
$profileId = ((Invoke-WebRequest -Uri "https://HostName:30000/StoreName/api/Profile?email=alice@example.com" -Headers @{"accept"="application/json";"Authorization"="Bearer YOURKEY"}).Content | ConvertFrom-Json).ProfileId
# Get delegations created by user
$wc = Invoke-WebRequest -Uri "https://HostName:30000/StoreName/api/Delegation?delegator=$($profileId)" -Headers @{"accept"="application/json";"Authorization"="Bearer YOURKEY"}
$wc.Content | ConvertFrom-Json

Get all delegations

$wc = Invoke-WebRequest -Uri "https://HostName:30000/StoreName/api/Delegation" -Headers @{"accept"="application/json";"Authorization"="Bearer YOURKEY"}
$wc.Content | ConvertFrom-Json

Get all active delegations

$wc = Invoke-WebRequest -Uri "https://HostName:30000/StoreName/api/Delegation" -Headers @{"accept"="application/json";"Authorization"="Bearer YOURKEY"}
($wc.Content | ConvertFrom-Json) | Where-Object { $_.Active -eq $true}

Get all delegations to a delegatee

$wc = Invoke-WebRequest -Uri "https://HostName:30000/StoreName/api/Delegation?delegatee=35059309-6738-4199-8142-f2f1d0c4efff" -Headers @{"accept"="application/json";"Authorization"="Bearer YOURKEY"}
$wc.Content | ConvertFrom-Json

Upload media

$enc = [system.Text.Encoding]::UTF8
$fileContent = $enc.GetBytes("the file content") 

$body = @{
    Name = "fileName.txt"
    Content = $fileContent
}
$wc = Invoke-WebRequest -Uri "https://HostName:30000/StoreName/api/Media" -Headers @{"accept"="application/json";"Authorization"="Bearer YOURKEY"} -Method Post -Body (ConvertTo-Json $body)
$wc.Headers.Location # The Location contains the UniqueId for the created media