events v1 to acknowledge incident by key

events-api

(Mayank) #1

Hi All ,

I am using events v1 API for acknowledge incident based on the key.

Steps Followed ;

Create service and integrated with events v1 API (integration key )
created incodent from frontend and get the incident key
Calls below python code with two inputs .

#!/usr/bin/env python

import json
import requests

SERVICE_KEY = “***” # ENTER EVENTS V1 API INTEGRATION KEY HERE
INCIDENT_KEY = “dddf7f1af56740ed9b4c2e6664ad6038” # ENTER INCIDENT KEY

def ack_incident():
# Triggers a PagerDuty incident without a previously generated incident key
# Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events

payload = {  # Payload is built with the least amount of fields required to trigger an incident
    "service_key": SERVICE_KEY,
    "event_type": "acknowledge",
    "incident_key": INCIDENT_KEY,
    "description": "Example alert on host1.example.com",
    #"contexts": "https://app.pagerduty.com"
}

response = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json',
                         data=json.dumps(payload))

if response.json()["status"] == "success":
    print response.text
    print('Incident Acknowledged')
else:
    print(response.text)  # print error message if not successful

if name == ‘main’:
ack_incident()

Though it is giving success response but the incident is in triggered state rather than acknowledged …>

Can some help me out on this ??


(Jade Paoletta) #3

Hi there!

I was able to test your script and have it successfully acknowledge an incident in my own test account. We may need some additional information specific to your account to continue troubleshooting. Please send us an email at support@pagerduty.com and we’ll be happy to assist you!

Best,


(system) closed #4

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.