Share Request via API / Powershell
When I'm trying to share a request to a group via API and I'm having some issues and need assistance. Any feedback would be appreciated, but for my purposes in my environment I need to utilize PowerShell.
if I have the square brackets [] I get:
Invoke-WebRequest : The remote server returned an error: (500) Internal Server Error.
At line:17 char:21
if I exclude them I get
Value provided for field(s) groups is invalid","status_code":"4001"
Here is my code below:
$TicketNumber = "123456"
$ServerURL = "https://servicedesk.url"
$ApiArea = "requests/"+$TicketNumber+"/share"
$ApiKey = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
$inputData = @"
{"share": {"groups": [{"site": "SiteName","name": "GroupName"}]}}
"@
$URI = $ServerURL + "/api/v3/" + $ApiArea +"?TECHNICIAN_KEY=$ApiKey&input_data=$inputdata&format=json"
$WebRequestOutput = Invoke-WebRequest -Method PUT -Uri $URI -UseBasicParsing -Verbose
$WebRequestOutput.Content