Rest API Update Incident Status

jaypman
Kilo Contributor

I'm trying to update that status of an incident and was wondering if the rest call is correct?   (using C# RestSharp)

public void UpdateIncidentStatus(string incidentNumber, string newStatus)

{

                      var request = new RestRequest("/api/now/table/incident?sysparm_query=number={incident_number}", Method.PUT) { RequestFormat = DataFormat.Json };

                      request.AddParameter("incident_number", incidentNumber, ParameterType.UrlSegment);

                      request.AddBody(new { status = newStatus });   // uses JsonSerializer

                      var response = client.Execute<RootObject>(request);

                      if (response.StatusCode == HttpStatusCode.NotFound)

                              throw new Exception(response.ErrorMessage);

}

11 REPLIES 11

I updated the discussion and you should now see the options to mark replies as "correct" and "helpful"



Cheers,



Dan


I'm working on the similar requirement. Can you share the business rule for update scenario, how are you checking if the incident already exists in another instance?