Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,603
Community Members
 
Community Events
176
Community Groups

Alerts API - Close Alert

I've made a few successful API calls using the same integration key (Get Alerts, Update Description, Add Tag), but while trying to CLOSE ALERT, I get "The remote server returned an error: (400) Bad Request"

Any idea what I could be missing here?

<SNIP>

PS C:\> $closeAlertURL
https://api.opsgenie.com/v2/alerts/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-xxxxxxxxxxxxx/close

PS C:\> Invoke-RestMethod -Method POST -Uri $closeAlertURL -Headers $global:OpsGenieAPIHeader

Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At line:1 char:1
+ Invoke-RestMethod -Method POST -Uri $closeAlertURL -Headers $global:O ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

<SNIP>

1 answer

1 accepted

0 votes
Answer accepted

I figured out the problem.

Even though I'm not using any of the OPTIONAL fields in the JSON body, I MUST have an empty JSON body passed with the request.

Here's what worked for me:

<SNIP>

PS C:\Windows\System32> $closeAlertURL
https://api.opsgenie.com/v2/alerts/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-xxxxxxxxxxxxx/close

PS C:\> $post_message = @{}
$post_message_JSON = $post_message | ConvertTo-Json

PS C:\> Invoke-RestMethod -Method POST -Uri $closeAlertURL -Headers $global:OpsGenieAPIHeader -Body $post_message_JSON

</SNIP>

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS

Atlassian Community Events