Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Not able to resolve incident using restapi

rajesh_solanki
Kilo Explorer

Hi ,

I m trying to resolve an incident using restapi. This is what I have done.

1) via rest api I have populated every field it needs for resolving an incident. (in my pay load I m not settings State : 6 . I have another request for resolving incident)

2) At this moment I can go in SNOW url , open my incident and if I click resolve button , incident goes in resolved state.

3) if I do step 1 again and then submit another rest api pay load which ONLY has {"state":6} it should move incident in Resolved state right ? even though I get error 200 in my response , I still do not see ticket in resolved state

4) why the State field is not updating when using RestAPI ?

what am I missing ?

23 REPLIES 23

Well in my case i m using PUT and it is updating every field except state. So i would be curious to know why POST would help ?


treycarroll
Giga Guru

Sorry for the bad advice.     PUT is the correct method for an update.   I have just used other systems that tolerate POST for updates.



I am able to PUT to an INC on my developer instance with the following JSON payload:



{"state":"6"}




Response





200 OK



Headers



Cache-Control


no-cache,no-store,must-revalidate,max-age=-1



Content-Encoding


gzip



Content-Type


application/json;charset=UTF-8



Date


Thu, 01 Jun 2017 22:00:36 GMT



Expires


0



Pragma


no-store,no-cache



Server


ServiceNow



Strict-Transport-Security


max-age=15768000; includeSubDomains;



Transfer-Encoding


chunked



X-Is-Logged-In


true





Response Body


{ "result": { "parent": "", "made_sla": "true", "caused_by": "", "watch_list": "", "upon_reject": "cancel", "sys_updated_on": "2017-06-01 22:00:36", "child_incidents": "", "hold_reason": "1", "approval_history": "", "number": "INC0000054", "resolved_by": { "link": "https://dev26655.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441", "value": "6816f79cc0a8016401c5a33be04be441" }, "sys_updated_by": "admin", "opened_by": { "link": "https://dev26655.service-now.com/api/now/table/sys_user/681b365ec0a80164000fb0b05854a0cd", "value": "681b365ec0a80164000fb0b05854a0cd" }, "user_input": "", "sys_created_on": "2015-11-02 20:49:08", "sys_domain": { "link": "https://dev26655.service-now.com/api/now/table/sys_user_group/global", "value": "global" }, "state": "6", "sys_created_by": "itil", "knowledge": "false", "order": "", "calendar_stc": "", "closed_at": "", "cmdb_ci": { "link": "https://dev26655.service-now.com/api/now/table/cmdb_ci/26e44e8a0a0a0bb40095ff953f9ee520", "value": "26e44e8a0a0a0bb40095ff953f9ee520" }, "delivery_plan": "", "impact": "1", "active": "true", "work_notes_list": "", "business_service": "", "priority": "1", "sys_domain_path": "/", "rfc": "", "time_worked": "", "expected_start": "", "opened_at": "2015-11-02 20:49:08", "business_duration": "", "group_list": "", "work_end": "", "caller_id": { "link": "https://dev26655.service-now.com/api/now/table/sys_user/97000fcc0a0a0a6e0104ca999f619e5b", "value": "97000fcc0a0a0a6e0104ca999f619e5b" }, "resolved_at": "2017-06-01 22:00:36", "approval_set": "", "subcategory": "", "work_notes": "", "short_description": "SAP Materials Management is slow or there is an outage", "close_code": "", "correlation_display": "", "delivery_task": "", "work_start": "", "assignment_group": { "link": "https://dev26655.service-now.com/api/now/table/sys_user_group/d625dccec0a8016700a222a0f7900d06", "value": "d625dccec0a8016700a222a0f7900d06" }, "additional_assignee_list": "", "business_stc": "", "description": "", "calendar_duration": "", "close_notes": "", "notify": "1", "sys_class_name": "incident", "closed_by": "", "follow_up": "", "parent_incident": "", "sys_id": "d71da88ac0a801670061eabfe4b28f77", "contact_type": "phone", "incident_state": "6", "urgency": "1", "problem_id": { "link": "https://dev26655.service-now.com/api/now/table/problem/d7296d02c0a801670085e737da016e70", "value": "d7296d02c0a801670085e737da016e70" }, "company": { "link": "https://dev26655.service-now.com/api/now/table/core_company/31bea3d53790200044e0bfc8bcbe5dec", "value": "31bea3d53790200044e0bfc8bcbe5dec" }, "reassignment_count": "0", "activity_due": "2015-11-24 17:47:36", "assigned_to": "", "severity": "3", "comments": "", "approval": "not requested", "sla_due": "2015-11-02 12:45:24", "comments_and_work_notes": "", "due_date": "", "sys_mod_count": "96", "reopen_count": "", "sys_tags": "", "escalation": "3", "upon_approval": "proceed", "correlation_id": "", "location": { "link": "https://dev26655.service-now.com/api/now/table/cmn_location/db9a923c0a0a0a6501068d6eaec25ee0", "value": "db9a923c0a0a0a6501068d6eaec25ee0" }, "category": "software" } }

I see that since I built my JSON using the little builder widget the value is in quotes.


so what roles you have for the ID which you used to resolve it ?


rajesh_solanki
Kilo Explorer

I have a user which has following roles. ( i m not using admin id)



find_real_file.png