Update Incident REST API - fields not updating

Hi,

I am trying to update an incident using your REST API, but I am unable to update the fields assignments and escalation_policy. I get a successful response, but the fields do not actually update. It may be that I am doing this incorrectly, but it is not very clear from your API docs on how to update those fields. Additionally, I would also like to update the field conference_bridge, but that is also not very clear in the API docs on how to do that. Can I get some clarification on how to update the fields assignments, escalation_policy, and conference_bridge using your REST API.

https://api-reference.pagerduty.com/#!/Incidents/put_incidents_id

Hi @hmejia,

I noticed from your payload that you are trying to both reassign an incident and delegate it to a new escalation policy at the same time. In my testing, I was only able to do one or the other at this endpoint.

Here’s a sample curl request to reassign the incident to a user:

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/vnd.pagerduty+json;version=2' --header 'From: example@email.invalid' --header 'Authorization: Token token=xxxxxxxxxxxxxxxx' -d '{
  "incident": {
    "type": "incident_reference",
    "assignments": [
      {
        "assignee": {
          "id": "PSVPSGN",
          "type": "user_reference"
        }
      }
    ]
  }
}' 'https://api.pagerduty.com/incidents/PV5TMPW' 

And here’s a sample curl request to delegate the incident to a new escalation policy:

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/vnd.pagerduty+json;version=2' --header 'From: example@email.invalid' --header 'Authorization: Token token=xxxxxxxxxxxxxxxx' -d '{
  "incident": {
    "type": "incident_reference",
    "escalation_policy": {
      	"id": "POWI1P1",
        "type": "escalation_policy"
    }
  }
}' 'https://api.pagerduty.com/incidents/PGV2DKM'

I would recommend comparing your request headers to the ones in these examples to ensure that they are in order. Note that the request email must match a login email of a user on the account with the permissions to make this change.

If you would like to have both an escalation policy reassignment and have an additional user notified, I would recommend using a Response Play. Here are our Response Play docs. You can also add conference bridges with Response Plays.

I hope that helps!

Hi @prupke,

Just to clarify, so you can not update the escalation policy, assignment, and conference bridge on the same request?

Additionally, how do format the body for a request to update the conference bridge, it’s not clear from the docs on how to do that.

@prupke,

Additionally, I am noticing that the incident type is not updating. From the docs, I see that valid incident types are incident and incident_reference. When I try to update an incident type from incident to incident_reference, the type does not update.

Hi @hmejia,

You should be able to make the update in one call using the call below:

{
    "incident": {
        "type": "incident_reference",
        "assignments": [
            {
                "assignee": {
                	"id": "PO1JF5L",
                    "type": "user_reference"
                }
            }
        ],
        "escalation_policy": {
            "id": "PO9Q3A2",
            "type": "escalation_policy_reference"
        },
           "conference_bridge": {
    	"conference_url": "sdasdasdasadasd.com/asdasdasdasdasdsasad",
    	"conference_number": "344324324"
    }
    }
}

As to the issue on type, would this be for a triggered Incident? What call are you making?

Cheers

Hi @chiedu,

It doesn’t though. When I try to update assignments and escalation policy on the same request, the escalation policy updates to what was specified in the request, but assignments does not, it updates to the current logged in user, not the user specified in the request. If I just update assignments, i.e do not include escalation policy in request, the assignment does update to user specified in the request.

For the issue type, yes status is triggered in UI when I try to update ,

the type is set as incident when I make a get request on the incident, https://api-reference.pagerduty.com/#!/Incidents/get_incidents_id. The type is also incident on response from PUT request, https://api-reference.pagerduty.com/#!/Incidents/put_incidents_id. Does not update.

Thanks for clarification on Conference Bridge.

Another question I have is, if an incident status is updated to resolved, can you no longer update it, i.e. set status back to acknowledged? From my testing, I can not update an incident once it is resolved.

Hi Humberto,

It is correct that once you set the status to resolved you can make no further changes to the incident.

I am testing the other set of question you have asked about updating the Escalation Policy and the Assignment together at the same time. You are saying that you have not been able to update the Escalation Policy and the Assignment at the same time in one call. Looking into it.

Thank you for your patience.

Kind regards,

@Humberto,

Please can you confirm that the user being assigned the Incident is associated with the Escalation Policy in question?

If the Incident has been triggered as Incident, it can’t be changed to Incident_reference. It is however possible for an Incident via the API to be triggered as either Incidentor Incident_reference.

Cheers,

@chiedu,

Thanks for the clarification on updating the incident type and status. As for updating the assignee and escalation policy on the same request, the user was not assigned to the escalation policy. If the user is assigned to the escalation policy, then the Assignments field list does update.

But after further investigation, I have found that in order to do this though, you have to first update the escalation policy to include the user.

PUT escalation_policies/{escalationId}

{
  "escalation_policy": {
    "type": "escalation_policy",
    "escalation_rules": [
      {
        "escalation_delay_in_minutes": 30,
        "targets": [
          {
            "id": "{userId}",
            "type": "user_reference"
          }
        ]
      }
    ]
  }
}

Then you have to make a request to update the incident’s escalation policy, even though escalation policy is already associated with that incident.

PUT incidents/{incidentId}

{
  "incident": {
    "type": "incident",
    "escalation_policy": {
    	"id": "{escalationId}",
    	"type": "escalation_policy_reference"
    }
  }
}

At this point the assignments field list is updated to include the user added to the escalation policy.

So it seems that if the user is not on the escalation policy, then the you can not add them by simply updating the assignments field list on the incident, i.e.

PUT incidents/{incidentId}

{
  "incident": {
    "type": "incident",
    "assignments": [
    	{
    		"assignee": {
    			"id": "{userId}",
    			"type": "user_reference"
    		}
    	}
    ]
  }
}

the above request does not do anything, i.e. does not add the user to the assignments field list. Is this the expected behavior?

Hi Humberto,

I just tested reassigning an incident to a user who is not on the escalation policy associated with the incident and it worked. Here is request format I used:

{ "incident": {
	"id": "PXXXXXX",
	"type": "incident",
	"assignments": [
		{
		"assignee": {
			"id": "PXXXXXX",
			"type": "user_reference",
			"summary": "Isabella Applen",
			"self": "https://api.pagerduty.com/users/PXXXXXX",
			"html_url": "https://subdomain.pagerduty.com/users/PXXXXXX"
		}
	}]
}
}

Let me know if you have any questions. If you do get any error using a request formatted this way, please copy and paste it onto this ticket.

Best Regards,

Hi @IsabellaApplen,

What endpoint are you referencing? The update incident endpoint, does not include the incident id in the request schema. I tried it anyways, but no success, the assignee is not added to the list of assignments. Is it possible to send you, or a customer support specialist, a repro screen recording to give you more context into the issue? I can not upload videos through this.

If the user is not assigned to the escalation policy associated to the incident, I can not add a user, an assignee, to the the assignments list by updating the assignments field through the endpoint, I get a successful response, 200 status code, but the user is not added.

Humberto

This is not spam, do not flag

Hi @hmejia, I was also able to get this to work using the Manage incidents endpoint. Here is the full curl request I sent (with sensitive info redacted):

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/vnd.pagerduty+json;version=2' --header 'From: email@example.invalid' --header 'Authorization: Token token=xxxxxxxxxxxxxxxx' -d '{
  "incidents": [
    {
      "id": "PP35S7E",
      "type": "incident_reference",
      "assignments": [
        {
          "assignee": {
            "id": "PRQZR7N",
            "type": "user_reference"
          }
        }
      ]
    }
  ]
}' 'https://api.pagerduty.com/incidents'

I hope that helps. I’m not sure who marked your last message as spam, but rest assured it was not us. :slight_smile:

Hi @prupke,

That does update the assignments field, but only a subset of the fields listed in the request schema for Manage Incidents endpoint actually update. Those issues are out of scope for this filed ticket so I won’t list them here and my preference is to use the Update an incident endpoint. The original question was in regards to the Update an incident endpoint not the Manage Incidents endpoint. Does that mean that the Update an incident endpoint has a bug i.e. you can not update the assignments field using the Update an incident endpoint?

Humberto

Hi @hmejia,

Yes, based on my testing, if you are using the Update an incident endpoint and would like to both assign it to a new user and delegate it to a different escalation policy, this would require two separate API calls.

I noticed from your payload that you are trying to both reassign an incident and delegate it to a new escalation policy at the same time. In my testing, I was only able to do one or the other at this endpoint.

@prupke,

Sounds good, thank you guys for all your help, very much appreciated.

2 Likes

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