OpsGenie REST API not returning any results

Tom Davison
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 10, 2023

Hello,

I have been requested to create a Dashboard that displays the status of our Key infrastructure objects. I am trying to utilize the Opsgenie REST API to obtain a list of open alerts within a saved search. However, in Postman, when I try this, I don't get any results in the Body. I'm not sure if I am doing this correctly.

The GET URL I am using is:

https://api.opsgenie.com/v2/alerts?query="status: open"&searchIdentifier="Meraki - network has become unreachable"&searchIdentifierType=id&offset=0&limit=20&sort=createdAt&order=desc

OpsGenieAPI.JPG

 

 

Thank you for any help on this one,
Tom

1 answer

1 vote
Arumugam M
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 12, 2023

Hello Tom, 

This is Arumugam from Atlassian support and I'm happy to help!

I understand that you are working with our APIs and not getting the expected results. 

While looking at the query you constructed, it seems that the query is not URI encoded. 

Please follow the steps below to get the results:

1. Go to your Opsgenie instance list view page and construct the search query in UI and search for alerts and see if it is fetching the results that you want. 

2. Once you have the search query, now you can use that from Postman or any programming language. However, you would need to URI encode the search parameter before appending it to the API endpoint. 

Here is a sample CURL request of how it should be for your reference:

curl -XGET -H "Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889" 'https://api.opsgenie.com/v2/alerts?query=status%3Aopen&offset=7&limit=10&sort=createdAt&order=desc'

Kindly try the same an let me know how it goes. 

Thanks, 
Arumugam

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events