I have found the best way to find out how to use the API is by using the Resilient UI. Here is an example where I'm reassigning multiple incidents to a new workspace:
curl 'https://server/rest/orgs/230/incidents' -X PATCH -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:76.0) Gecko/20100101 Firefox/76.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Content-Type: application/json' -H 'X-sess-id: 0be97c6663be62d2282b693990d5e9fc' -H 'handle_format: ids' -H 'text_content_output_format: objects_convert' -H 'browser_locale: en' -H 'X-Requested-With: XMLHttpRequest' -H 'Cookie: _ga=GA1.2.1382814266.1575940211; JSESSIONID=57D84D593D7B19A0A97C7DEB9B40964C; CSRF_TOKEN=7b2276616c7565223a223935656236313738653636633432373564373234356430373362333632656431227d' --data-raw '{"patches":{"26044":{"version":7,"changes":[{"old_value":{"object":{"id":66,"name":"Default workspace"}},"new_value":{"object":"228"},"field":{"name":"workspace","id":null,"null":false}}]},"26045":{"version":32,"changes":[{"old_value":{"object":{"id":66,"name":"Default workspace"}},"new_value":{"object":"228"},"field":{"name":"workspace","id":null,"null":false}}]}}}'
Here is the actual POST data:
{
"patches": {
"26044": {
"version": 7,
"changes": [
{
"old_value": {
"object": {
"id": 66,
"name": "Default workspace"
}
},
"new_value": {
"object": "228"
},
"field": {
"name": "workspace",
"id": null,
"null": false
}
}
]
},
"26045": {
"version": 32,
"changes": [
{
"old_value": {
"object": {
"id": 66,
"name": "Default workspace"
}
},
"new_value": {
"object": "228"
},
"field": {
"name": "workspace",
"id": null,
"null": false
}
}
]
}
}
}Notice that you need the old data and the current version number of the incident. This is necessary so that the system can determine if the data has changed since you last saw it. This is to prevent the "last writer" wins scenario. I supposed you could claim there should be a way to "force" PATCH. If you want to force update you have to use the PUT operation on an incident which as you pointed out requires all the incident details.
So pretty much either way you'll need the current incident data to use either PATCH or PUT.
The
changes is an array so you can send updates for multiple fields at the same time.
Ben
------------------------------
Ben Lurie
------------------------------