Resolving an incident using pagerduty events v2 or incident api

def resolve_incident(self, device_id, message):
    url = "https://events.pagerduty.com/v2/enqueue"
    print(url)

    headers = {
        "Accept": "application/vnd.pagerduty+json;version=2",
        "Authorization": "Token token={}".format(self.pagerDuty_api_key),
        "From": "xys@assa.com",
        "Content-Type": "application/json"
    }
    payload = {
        "routing_key": self.pagerDuty_integration_key,
        "dedup_key": device_id,
        "event_action": "acknowledge"
        }

    r = requests.post(url, data=json.dumps(payload), headers=headers)
    if r.status_code == 200:
        print(r.json)
        return True
    else:
        print(r.status_code)
        print(r.text)
        return False

This results in
202
{“status”:“success”,“message”:“Event processed”,“dedup_key”:“000111222”}

But the incident is not getting resolved.

I tried using the incident api update, but i get
400
{“error”:{“message”:“Arguments Caused Error”,“code”:2002,“errors”:[“Open incident with matching dedup key already exists on this service”]}}
False

how could i resolve the incident using API?

Looks like you’re sending an “acknowledge” event_action instead of a “resolve” event_action. Take a peek at the Event API v2 docs here: https://developer.pagerduty.com/api-reference/reference/events-v2/openapiv3.json/paths/~1enqueue/post.

To resolve an incident via REST API, you’ll need to use the dedup_key to make a query to get the incident ID for that dedup_key (incident_key), then make a call to resolve the incident using the incident ID.

Doug