Missed Team ’24? Catch up on announcements here.

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

API support use from free trial version

Kenny Cho October 13, 2021

Is there API support use for the OpsGenie free trial version?  I have noticed that when I make an API post call to https://api.opsgenie.com/v2/alerts or https://api.eu.opsgenie.com/v2/alerts,

I would get a authentication error using the API key that was used from the OpsGenie UI under Teams -> t$eam_name -> Integrations -> $API_Name.

 

{
"message": "Could not authenticate",
"took": 0.0,
"requestId": "ba4d56cd-2a7b-4608-8803-1433d4d8f047"
}
I used the following in the API Post call to authenticate:
Key = GenieKey
Value = $My_API_Key_matching_with_OpsGenie_API_Key
Content-type = application/json
Add to = Header
However, it would recognize the 2 API post calls that I did today from another app calling the API post to create the alert but I don't see the alert created in OpsGenie.
Additionally, I noticed that when I go to the Settings tab and then under Integrations on the left panel, I only see "Slack" as a choice.  I don't see the API under the Integrations.  So I'm not sure whether the fact I'm using a free trial is preventing me from sending API POST calls to OpsGenie to create the alerts.
Any help would be appreciated.
Thanks.

1 answer

1 accepted

1 vote
Answer accepted
Nick H
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 13, 2021

Hi @Kenny Cho ,

Our API should be supported even on the Free plan. But you need to use the API key from an API integration. It sounds like you are using an API key from the API Key Management tab instead.

Under the Free plan, you need to add integrations from under a team. Once you save an API integration, you should be able to use this as the GenieKey to create alerts:

apicommm1.jpg

Hope this helps! Let us know if you have any other questions, issues, etc.

Kenny Cho October 13, 2021

Thanks Nick,

I went to "Teams" -> $team_name -> Integrations -> $API_Name to get the API key so I don't think that is it.

I tried again using this curl command to create the OpsGenie alert but it still gives me an authentication error:

 

curl --location --request POST 'https://api.opsgenie.com/v2/alerts' \   

--header 'Content-Type: application/json' \

--header 'GenieKey: b882d083-ef33-4dad-b31e-003ff61fe539' \

--data-raw '{

    "message": "An example alert message",

    "alias": "Life is too short for no alias",

    "description":"Every alert needs a description",

    "responders":[

        {"id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c", "type":"team"},

        {"name":"NOC", "type":"team"},

        {"id":"bb4d9938-c3c2-455d-aaab-727aa701c0d8", "type":"user"},

        {"username":"trinity@opsgenie.com", "type":"user"},

        {"id":"aee8a0de-c80f-4515-a232-501c0bc9d715", "type":"escalation"},

        {"name":"Nightwatch Escalation", "type":"escalation"},

        {"id":"80564037-1984-4f38-b98e-8a1f662df552", "type":"schedule"},

        {"name":"First Responders Schedule", "type":"schedule"}

    ],

    "visibleTo":[

        {"id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c","type":"team"},

        {"name":"rocket_team","type":"team"},

        {"id":"bb4d9938-c3c2-455d-aaab-727aa701c0d8","type":"user"},

        {"username":"trinity@opsgenie.com","type":"user"}

    ],

    "actions": ["Restart", "AnExampleAction"],

    "tags": ["OverwriteQuietHours","Critical"],

    "details":{"key1":"value1","key2":"value2"},

    "entity":"An example entity",

    "priority":"P3"

}'

{"message":"Could not authenticate","took":0.0,"requestId":"f75bde16-dbfc-4e2a-9943-6dcca6f951e7"}.

 

% curl -X GET 'https://api.opsgenie.com/v2/alerts/requests/f75bde16-dbfc-4e2a-9943-6dcca6f951e7'

{"message":"Could not authenticate","took":0.0,"requestId":"149ecb74-debf-4846-9e71-f91fa9784ea9"}%                                                                                                                                                

% curl -X GET 'https://api.opsgenie.com/v2/alerts/requests/f75bde16-dbfc-4e2a-9943-6dcca6f951e7' -H 'Authorization: GenieKey b882d083-ef33-4dad-b31e-003ff61fe539'

{"message":"Request not found. It might not be processed, yet.","took":0.004,"requestId":"1a9794bf-2985-4d4e-8134-48dec34f8264"}

It matches up with the API key from the OpsGenie UP under API integrations:

Screen Shot 2021-10-13 at 10.56.25 AM.png

I'm not sure what I'm doing wrong because everything seems to align here.

Please help.

Thanks,

Kenny

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

Try something as simple as thing:

curl -X POST https://api.opsgenie.com/v2/alerts -H "Content-Type: application/json" -H "Authorization: GenieKey API_KEY" -d '{"message": "An example alert message"}'

and let us know whether or not that works. 

 

Also, you may want to consider editing your last post and removing your API key so others do not have access to your account. Or you can refresh the API integration's key, save it, and use that new one moving forward.

Like Steffen Opel _Utoolity_ likes this
Nick H
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 13, 2021

^ Note as well, you will want to enter your integration's API key in that curl command where it shows API_KEY.

Kenny Cho October 13, 2021

Thank you.  The curl POST API command worked and I was able to see the message in the Alerts section.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events