Hello,
I am working on automating our employee offboarding process and one of the items that would save me a good chunk of time is using the API to get all of the assets associated with a particular user.
I am currently stuck on the formatting of the API call using the PowerShell snippet below.
$Header = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("MY_API_KEY"))}
$id = 11000998613
$user_id = "user_id:$id"
$user_asset = invoke-RestMethod -URI https://novinium.freshservice.com/api/v2/assets?include=type_fields'&'query=$user_id -Headers $Header -ContentType "application/json" -Method Get
I am receiving back:
Error: (400) bad request
message=Given query is invalid, expected format “keyword:value OPERATOR keyword:‘string’ OPERATOR keyword:>‘yyyy-mm-dd’ OPERATOR keyword:<integer”. Space is mandatory between key/value pair and operator. Please check the paranthesis if there are any.
When I use Fiddler to exam the API call I see that my Request Headers contains: GET /api/v2/assets?include=type_fields&query=user_id:11000998613 HTTP/1.1
Any assistance with this would be greatly appreciated!