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

Hi Jason,



Please mark the reply as answer, if you feel it is answered. It adds value to the community members and encourages them to help the community.



Thanks


Hmm.. for some strange reason, this posting does not allow me to mark as answered.   There are no buttons that says "correct answer" that allows me to mark the reply as the correct answer.


I just figured out that when creating a discussion I did not mark the checkbox stating it was a question so that is why I'm not seeing those buttons to mark a reply as an answer.   I'll do this in future discussions/quesions moving forward.


We can get that changed.   bianca.vaccarini, right?


Yes Dan Bruhn can make that adjustment