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

Getting started with Opsgenie API

Sam January 11, 2021

Hi! I'm trying to get familiar with using Opsgenie's APIs (the alert APIs in particular), and I haven't been able to get any results at all.

I've tried using Postman to authorize myself using one the API keys found under "Settings" > "API Key Management", but that just always gets a 401 Unauthorized response.

I've also tried using curl from the command line as shown below:

curl -X GET 'https://api.opsgenie.com/v2/alerts/requests/' -H 'Authorization: xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx'

 But I keep getting results like:

curl: (1) Protocol "'https" not supported or disabled in libcurl
curl: (6) Could not resolve host: xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx'

When I use "http" instead of "https", I get a similar response.

Do you have any advice for returning some of the alerts used by your Opsgenie instance?

P.S. "eazyBI" is in the tags because I'd eventually want to use eazyBI's REST API feature to pull data from Opsgenie. But for now I'm trying to establish a connection.

1 answer

1 accepted

4 votes
Answer accepted
Nick H
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 11, 2021

Hi @Sam ,

You'll want to use the API key from an API integration to complete the Alert API requests.

Under the Standard and Enterprise plans, integrations can be added globally under the Settings tab >> Integration list tab. 

Or under all plans, integrations can be added under a team's Integrations tab - but will only be able to create alerts for the team it's configured under.

https://docs.opsgenie.com/docs/api-integration

API comm 1.jpg

Try adding one of these / testing, and let us know if you run into any other questions or issues!

Sam January 12, 2021

Thank you @Nick H , I can now connect to the API!

Michael Rogers
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!
January 12, 2021

@Sam @Nick H Would you be able to post a picture of how it looks in postman? I have the API key but am still getting a "Could not authenticate" error. Not sure I have it formatted right. 

Sam January 12, 2021

@Michael Rogers Did you put "GenieKey " before the API key? That worked for me.

image.png

Nick H
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2021

Hi @Michael Rogers ,

Remember the API key (or GenieKey) needed will be from an API integration:

API comm 4.jpg

 

Below are a few examples of our Alert API and Postman. I used our Alert API doc to grab the body in the request below: https://docs.opsgenie.com/docs/alert-api#create-alert

API comm 2.jpg

 

The only mandatory field is the message. For testing, you could use a body as simple as this:

API comm 3.jpg

 

Hope this helps! If you continue seeing a "Could not authenticate" error, let us know. Or feel free to share the syntax as well.

Like Raja Dorji likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events