API: Add Multiple Responders to an Incident

Hi guys,

Im trying to add multiple responders to an incident via the API but im having no luck. I have been looking at https://developer.pagerduty.com/api-reference/b3A6Mjc0ODE1MQ-create-a-responder-request-for-an-incident and my request works when only assigning one responder but fails when trying to add multiple.

Endpoint: https://api.pagerduty.com/incidents/{INCIDENT_ID}/responder_requests

Working (adding one responder):

{
    "requester_id": "USERID",
    "message": "TEST",
    "responder_request_targets": [
        {
            "responder_request_target": {
                "id": "XXX",
                "type": "user_reference"
            }
        }
    ]
}

Not working (trying to add multiple responders):

{
    "requester_id": "USERID",
    "message": "TEST",
    "responder_request_targets": [
        {
            "responder_request_target": {
                "id": "XXX",
                "type": "user_reference"
            }
        },
        {
            "responder_request_target": {
                "id": "XXX",
                "type": "user_reference"
            }
        }
    ]
}

Result from the above failed request:
Error 400 “Bad Request”

{
    "status": "unrecognized object",
    "message": "Object format is unrecognized",
    "errors": [
        "JSON parse error"
    ]
}

Any ideas?

Hi Ayush,

Thanks so much for reaching out!

I understand you are wanting to add multiple responders to an incident via the API. I’ll be glad to help!

Per the article you provided, you should be able to add the wanted users to the API in an array. That way you can add multiple responders to the incident with one request.

I would like to do some further investigating on what happens when you try to add multiple users. Could you send a copy of the JSON code you are using to add responders to support@pagerduty.com, so I can take a further look?

Please get back with me at your earliest convenience!

Cheers,
Amanda
Technical Support Specialist

Hey there Amanda,

Is the code snippet and error result in my original post of how im currently trying to make the request (multiple responders in an array format) not enough - what more information do you require so I can send you those details?

I am not too sure if my body request is in the correct JSON format as well.

Cheers,
Ayush

Ayush - this format worked for me using our online API reference tool (https://developer.pagerduty.com/api-reference/b3A6Mjc0ODE1MQ-create-a-responder-request-for-an-incident)

{
  "requester_id": "PIF4HMF",
  "message": "Please help with issue - join bridge at +1(234)-567-8910",
  "responder_request_targets": [
    {
      "responder_request_target": {
        "id": "P7JYNFK",
        "type": "user_reference"
      }
    },
    {
      "responder_request_target": {
        "id": "PUT9LUG",
        "type": "user_reference"
      }
    }
  ]
}
1 Like

Thanks for your help.

It seems that the problem lies with Postman and the inability to comment JSON code within the body (which is what I was doing) which Is why I was receiving the error 400 JSON parse error. Thanks for your help and apologies for the hassle!