Not able to create alert for user type. However I am able to create alert for teams.

anshu singh
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 23, 2024

I am trying to create alert for user type but I am getting below error. 

{
  "code": 40301,
  "message": "To perform this action, use an API key from an API integration.",
  "took": 0,
  "requestId": "da0e219a-53d9-42bd-add8-xxx"
}
Even though I am the org admin but still can't create the alert for a specific user. 
Rest Api Which I am using
Method: Post
However the get method is working with the rest api and also with the same api key but post method is not working.
Please advise.
Python code:
import requests

def opsGenieAlertCreation():

    authorization_token: str = 'GenieKey {0}'.format("xxxxxx-xxxx")

    headers = {

    'Content-Type': 'application/json',

    'Authorization': authorization_token

    }

    #incidentEscaltionOpsgenieTeamId = ops_genie_teamid

    incidentEscaltionOpsgeniePriority = "P1"

    api_url = 'https://api.opsgenie.com/v2/alerts'

    alert_data = {

        "message": "New incident was created",

        "responders": [

            {

                "type": "user",

                "id": "xxx@gmail.com"

            }

        ],

        "description": "test description",

        "priority": incidentEscaltionOpsgeniePriority,

        "tags": ["Incident", "Monitoring"]

    }

    

    response = requests.post(api_url, json=alert_data, headers=headers)

    

#calling above function

opsGenieAlertCreation()

1 answer

0 votes
Alan Violada
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 24, 2024

Hey Anshu, Alan from the Opsgenie Support team here.

In this case, you want to make sure that the API key you are using is from an API integration - All instances have the "Default API" integration, but you can also create your own:

Create an API integration 

 

Cheers,

Alan

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events