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

Thanks Rajesh,



Can you please share the result of this POST request ?


My SNOW admin has left for that day. I will update tomorrow.


I will try to send in few. but I did take look at Resolve button java script. its default code and we haven't changed anything.


so i created an incident.



then i did GET in sysid



then i did PUT my payload is



{"state":6,"urgency":3,"assigned_to": "Rajesh Solanki", "close_code":"Solved", "caller_id":"e2ebef694fb1b200571150ee0310c70e", "u_close_subcode":"Permanent","close_notes":"Auto Closed by postman","work_notes":"Alert deleted by postman"}



here is reply.



{


  "result": {


      "parent": "",


      "caused_by": "",


      "watch_list": "",


      "upon_reject": "cancel",


      "sys_updated_on": "2017-06-01 21:41:31",


      "u_close_subcode": "Permanent",


      "approval_history": "",


      "skills": "",


      "u_reported_by": {


          "link": "https://myservicenow.com/api/now/v1/table/sys_user/e2ebef694fb1b200571150ee0310c70e",


          "value": "e2ebef694fb1b200571150ee0310c70e"


      },


      "number": "XXXXXXXXXX",


      "state": "21",


      "sys_created_by": "restapi",


      "knowledge": "false",


      "order": "",


      "u_sla_responded": "true",


      "cmdb_ci": {


          "link": "https://myservicenow.com/api/now/v1/table/cmdb_ci/e736a1eb4f439600571150ee0310c761",


          "value": "e736a1eb4f439600571150ee0310c761"


      },


      "impact": "1",


      "u_outage_content": "",


      "active": "true",


      "work_notes_list": "",


      "u_vendor": "",


      "priority": "3",


      "sys_domain_path": "/",


      "business_duration": "",


      "group_list": "",


      "approval_set": "",


      "short_description": "Critical alert on Server XXXXXXX for directory /tmp. Space used 100%",


      "correlation_display": "",


      "work_start": "",


      "u_manager_notification": "",


      "additional_assignee_list": "",


      "u_requestor": "",


      "u_originating_ticket": "",


      "notify": "1",


      "sys_class_name": "incident",


      "closed_by": "",


      "follow_up": "",


      "parent_incident": "",


      "reassignment_count": "0",


      "assigned_to": "",


      "sla_due": "",


      "comments_and_work_notes": "",


      "escalation": "0",


      "upon_approval": "proceed",


      "correlation_id": "XXXX_XXXXX/XXXXXX",


      "made_sla": "true",


      "child_incidents": "0",


      "resolved_by": "",


      "sys_updated_by": "restapi",


      "opened_by": {


          "link": "https://myservicenow.com/api/now/v1/table/sys_user/e2ebef694fb1b200571150ee0310c70e",


          "value": "e2ebef694fb1b200571150ee0310c70e"


      },


      "user_input": "",


      "sys_created_on": "2017-06-01 21:29:28",


      "sys_domain": {


          "link": "https://myservicenow.com/api/now/v1/table/sys_user_group/global",


          "value": "global"


      },


      "u_hpsm_change_number": "",


      "calendar_stc": "",


      "closed_at": "",


      "u_alternate_contact": "",


      "business_service": "",


      "u_symptom": "degraded",


      "rfc": "",


      "time_worked": "",


      "expected_start": "",


      "opened_at": "2017-06-01 21:28:20",


      "work_end": "",


      "caller_id": {


          "link": "https://myservicenow.com/api/now/v1/table/sys_user/e2ebef694fb1b200571150ee0310c70e",


          "value": "e2ebef694fb1b200571150ee0310c70e"


      },


      "resolved_at": "",


      "subcategory": "Server",


      "work_notes": "",


      "u_substate": "",


      "close_code": "Solved",


      "assignment_group": {


          "link": "https://myservicenow.com/api/now/v1/table/sys_user_group/da4485ca4fd65640571150ee0310c75e",


          "value": "da4485ca4fd65640571150ee0310c75e"


      },


      "u_kb_article": "",


      "business_stc": "",


      "description": "Critical alert on Server XXXXXXX for directory /tmp. Space used 100%",


      "u_outage_title": "",


      "u_vendor_ticket": "",


      "calendar_duration": "",


      "close_notes": "Auto Closed by restapipostman",


      "u_customer_name": "RESTAPI RESTAPI",


      "sys_id": "f42c66524f0b3640571150ee0310c71a",


      "contact_type": "event_alert",


      "incident_state": "6",


      "urgency": "3",


      "problem_id": "",


      "company": "",


      "activity_due": "",


      "severity": "3",


      "u_search": "",


      "comments": "",


      "approval": "not requested",


      "u_first_call": "false",


      "due_date": "",


      "sys_mod_count": "1",


      "reopen_count": "0",


      "sys_tags": "",


      "u_broadcast_notification": "",


      "location": "",


      "category": "Servers & Storage"


  }


}


Hi Rajesh,



Please confirm the Header/Body data per below screenshots :



Screen Shot 2017-06-02 at 3.35.07 AM.png



Screen Shot 2017-06-02 at 3.35.30 AM.png



I checked in postman and it worked for me..



Also, for PUT method - you need to pass sys_id in the URL.