Reputation: 2714
I use ServiceNow REST API in my application.
I need to resolve existing incident.
For this purpose I use PUT
method and I can update some fields like short_description
, but if I try to update state
field then API does not update this field.
I use very simple C# code:
_restClient.BaseUrl = new Uri(string.Format("https://{0}.service-now.com", serverName));
var request = new RestRequest(string.Format("/api/now/table/incident/{0}", incidentId), Method.PUT)
{
RequestFormat = DataFormat.Json
};
request.Credentials = new NetworkCredential(userName, password);
request.AddBody(new { state = "6" });
var response = _restClient.Execute(request);
I try to update state
to value 6
because this value is Resolve
.
But the field is not updated via REST API. However I can Resolve my incident via web UI.
Why state field is not updated with the use of REST API?
Upvotes: 1
Views: 3180
Reputation: 56
The field that you are trying to update should not be read-only.
Upvotes: 2
Reputation: 69
It's possible that you are missing out filling the mandatory fields. Make note of all mandatory fields while you resolve an incident through WebUI and add these fields to the body of your PUT request.
You should share the request's responses as well. That could help discover what the problem might be.
Upvotes: 2
Reputation: 1557
One of possible causes of behavior of that is that there is access control lists (ACL) set up on that table. You can read about them for example here.
In one of the situations I've encountered, there was a special 'flow' of changing states that would forbid changing state of the ticket, unless the "automated_state_flow" parameter was set as false. Might it be the same in your situation? I'd try to send a request with following JSON:
{"automated_state_flow"="False";
"state" = "6"}
and then sent the second web request:
{"automated_state_flow"="False"}
Upvotes: 1