Bad request (Arguments Caused Error - 2002) on event creation with incident_key

Hi,

We use the incidents API (https://api.pagerduty.com/incidents) and recently added the incident_key to ensure we were deduplicating incidents at the time of creation. However recently we have been getting the above error and we don’t know why, can anyone shed some light on this?

We wrap the date and time (rounded to an hour) together with the distinct alert text, and hash this into the incident_key. We do this because we have an agent that runs in different locations which could trigger the same event.

An example payload is as follows:

{ "incident": { "type": "incident", "title": "WildFly service has stopped (prd-wholesale@hosted.redacted.com)", "service": { "id": "redacted", "type": "service_reference" }, "body": { "type": "incident_body", "details": "The WildFly service was discovered to be in a stopped state." }, "incident_key": "yhlegcrlmzryz2chczhdr3yyg4t_45nu9gd5cor5m1s=" } }

Which returns:

{"error":{"message":"Arguments Caused Error","code":2002,"errors":["Incident could not be assigned"]}} (HTTP/1.1 400 Bad Request)

Many thanks,

Ross

Hi @RossHarvey,

I think you might be sending those to the wrong API endpoint - the standard REST API - https://v2.developer.pagerduty.com/docs/incident-creation-api.

The REST API is synchronous and used for interacting with existing Incidents and other configuration items. Whilst it can be used for creating Incidents, it really shouldn’t be - it has a pretty severe rate limit on it. Technically you can create Incidents using this API but there’s no specific use-case I can think of that couldn’t be implemented with the Events API

The asynchronous Events API (either v1 or v2) is where it’s at, and Events API v1 has the incident_key argument - https://v2.developer.pagerduty.com/docs/trigger-events

Note that the Events API has a v2 which has some better features (https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2) - in this API the argument you’re looking for it dedup_key (some other fields have changed their name, so look out for that). If you have to make changes anyway, you might as well make it work with the new version, right?

Hope that helps,
@simonfiddaman

1 Like

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