I am having problems with the following PowerShell code to create an incident in Service Now
# Specify HTTP method
$method = "post"
$bodyObj = New-Object psobject
$bodyObj | Add-Member NoteProperty -Name short_description -Value "Sensor: $name has failed with status: $status"
$bodyObj | Add-Member NoteProperty -Name description -Value "test" #"$message $addition_info".Replace('"','')
$bodyObj | Add-Member NoteProperty -Name assignment_group -Value $sys_id
$bodyObj | Add-Member NoteProperty -Name caller_id -Value "ceb4e9bf1bb22700bce164606e4bcb06" #PRTG Monitoring
if ($service_offering -ne $null) {$bodyObj | Add-Member NoteProperty -Name service_offering -Value $service_offering}
if ($configuration_item -ne $null) {$bodyObj | Add-Member NoteProperty -Name cmdb_ci -Value $configuration_item}
if ($business_service -ne $null) {$bodyObj | Add-Member NoteProperty -Name business_service -Value $business_service}
$body = $bodyObj | ConvertTo-Json
log $body
# Send HTTP request
#$response = Invoke-RestMethod -Headers $headers -Method $method -Uri $uri -Body $body
$response = Invoke-WebRequest -Headers $headers -Method Post -Uri $uri -Body $body -UseBasicParsing
log $response.result
}
Catch
{
Log $_
}
It creates the incident and all fields are populated except description
When I take the exact same body (the result of log $body) and use that in the Service Now REST API Explorer, it works fine.