Error 422 Unprocessable Entity creating new Integration Action for CloudWatch integration.

Joel Bradley
Contributor
March 2, 2022

Hi All,

 

I'm trying to use the Integration API to create a new CloudWatch integration then dynamically add new integration actions to that integration.

The CloudWatch integration gets set up fine. I then take the values for IntegrationId and ApiKey from the new integration and try to add a new action to that integration.
I get error 422 Unprocessable Entity. It doesn't like the format of my json. I've been sure to only include mandatory fields.
Input params are as follows.

$uri = 'https://api.opsgenie.com/v2/integrations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/actions'
$api = 'GenieKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
$head = @{"Authorization" = "$api"}
$body = @{"type"="create";"name"="Create Alert -Test";"alias"="alias for this alert"} | ConvertTo-Json
Or
$body = '{\"type\":\"create\",\"name\":\"Create Alert -Test\",\"alias\":\"alias for this alert\"}'

$data = Invoke-RestMethod -Uri $uri -Method Post -Headers $head -ContentType "application/json" -Body $body

The response is:
Invoke-RestMethod : The remote server returned an error: (422) Unprocessable Entity.
At line:1 char:9

Can anyone help me to get the integration to accept this JSON?

Bear in mind, this is a CloudWatch API integration and not the Default API integration.

Any assistance would be greatly appreciated.

1 answer

1 accepted

0 votes
Answer accepted
John M
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 2, 2022

Hi Joel,

It looks like the following fields are also required for the create action:

 

"user": "{{user}}",
"note": "{{note}}",
"source": "{{source}}",
"message": "{{message}}",
"description": "{{description}}",
"entity": "{{entity}}"

That doesn't seem to be very clear in the docs; I will put in a request to have them updated. 
Joel Bradley
Contributor
March 3, 2022

Thank you John.
The requests are now getting through.

Like John M likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events