Rest API Assign Incident to Multiple Users

Hi,

We are using the Rest API. We want to assign an Incident to multiple users. We have used the following request:

{
“incident”: {
“type”: “incident_reference”,
“assignments”: [{
“assignee” : {
“id”: “P0RAXK1”,
“type”: “user_reference”
},
“assignee” : {
“id”: “P0RAXK2”,
“type”: “user_reference”
}
}]

}
}

But it assigned the last user. Is there any way we can assign multiple users to the Incident?

Regards,
Sonal

Hey Sonal! You should be able to assign multiple users to the incident if you remove the curly braces that wraps around both the assignees. For example:

{ 
   "incident":{ 
      "type":"incident",
      "title":"The server is on fire.",
      "service":{ 
         "id":"PRXXXXX",
         "type":"service_reference"
      },
      "urgency":"high",
      "incident_key":"baf7cf21b1da41b4b0221008339ff357",
      "body":{ 
         "type":"incident_body",
         "details":"A disk is getting full on this machine. You should investigate what is causing the disk to fill, and ensure that there is an automated process in place for ensuring data is rotated (eg. logs should have logrotate around them). If data is expected to stay on this disk forever, you should start planning to scale up to a larger disk."
      },
      "assignments": [ 
         "assignee": { 
            "id":"PSXXXXX",
            "type":"user_reference"
         },
         "assignee": { 
            "id":"PTXXXXX",
            "type":"user_reference"
         }
      ]
   }
}

Hope this helps!

A side note / correction about the schema the API expects:
https://api-reference.pagerduty.com/#!/Incidents/put_incidents_id

“Inline Model 2” or similar object types throughout our API reference refers to an unnamed type of object that is defined ad-hoc in the scope of the resource.

So, when the API schema reference says “Array[Inline Model 2]”, it means an array of objects whose schema is defined in the lower levels of the schema definition of that resource, and it is labeled “Inline Model 2”.

In this case, the expected schema is thus an array of objects that have a single property, “assignee”.

The reason why it used only the last assignee is because both assignees were declared inside of an object, and because keys must be unique, one of the keys was discarded in the JSON serialization or de-serialization process.

The correct way to declare assignments would thus be to make each assignee entry its own object with the one “assignee” property containing the user reference. What that looks like when JSON-encoded:

    "assignments": [ 
        {
            "assignee": { 
                "id":"PSXXXXX",
                "type":"user_reference"
            }
        },
        {
            "assignee": { 
                "id":"PTXXXXX",
                "type":"user_reference"
            }
        }
    ]

Cheers!

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