I can get an alert successfully created with this PS scriptlet:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$body = {
"priority"="P1";
"message"="TESTING JIMMY example alert message";
"alias"="testingjimmy";
"description"="TESTING JIMMY Every alert needs a description"
}
$url="https://api.opsgenie.com/v2/alerts?apiKey=xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" I
nvoke-RestMethod -Method Post -ContentType "application/json" -Uri $url -Body (ConvertTo-Json $body)
But, I get "422 Unprocessable Entity" with every single option I chose (id, tiny, alias) in the below with proper modifications:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$header = {
"Authorization"="GenieKey "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx"))
}
$url="https://api.opsgenie.com/v2/alerts/testingjimmy/close?identifierType=alias"
Invoke-RestMethod -Method Post -ContentType "application/json" -Header $header -Uri $url
I've tried RequestIDs and the Tiny#s (alert#) too, with zero luck. The API service that this is tied to in the back end has the proper settings to close the alert as well.
Any ideas? I assume
I used several references, this is the one I used the most:
https://docs.opsgenie.com/docs/alert-api