Search code examples
c#.netservicenow

Can't resolve ServiceNow incident using REST API


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?


Solution

  • The field that you are trying to update should not be read-only.