You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
When posting with Postman, it works fine, but when I try to create an incident with the Python API, I get:
opsgenie_sdk.exceptions.AuthenticationException: You are not authorized to perform this action: (401)
Reason: Unauthorized: apiKey is invalid or integration is disabled
Here is a super simplified version of the python, opsgenie_api_key is just the guid without the 'GenieKey ' prefix:
def simple_create_incident(opsgenie_api_key, message='Alert', description='Description', priority='P5', asynchronous=False):
create_response, request_id = None, None
conf = opsgenie_sdk.configuration.Configuration()
conf.api_key['Authorization'] = opsgenie_api_key
api_client = opsgenie_sdk.api_client.ApiClient(configuration=conf)
incident_api = opsgenie_sdk.IncidentApi(api_client=api_client)
asc_time = time.asctime()
message = f'{message} @ {asc_time}'
body = opsgenie_sdk.CreateIncidentPayload(message=message, description=description, priority=priority)
if asynchronous:
thread = incident_api.create_incident(create_incident_payload=body, async_req=True)
create_response = thread.get()
else:
create_response = incident_api.create_incident(create_incident_payload=body)
request_id = incident_api.api_client.last_response.getheader('X-Request-ID')
return create_response or request_id
Hi Matt!
The error response you're getting *usually* indicates that the API key you're using is incorrect or has been deleted or rotated in your Opsgenie account. Using your example code, I was able to set that up and successfully generate new incidents, when using an api key generated from the 'API Key Management' section of the app, granted with the 'Create and Update' rights.
Could I have you generate a new API key in your account with those rights granted, and test it out once again? If you're still getting the same error, please let me know, and I we can take a closer look.
Thanks!
Justin
Hi Justin,
I am facing the same issue as above.
I have created a new API key with 'Create and Update' rights. Using this key iam getting the below exception.
opsgenie_sdk.exceptions.AuthenticationException: You are not authorized to perform this action: (403)
Can you please help me with this?
Thanks,
Kartik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.