Closed nntrn closed 2 months ago
Delete a record from the Incident table.
curl "https://instance.servicenow.com/api/now/table/incident/d977b66a4f411200adf9f8e18110c7b2" \
--request DELETE \
--header "Accept:application/json" \
--user 'username':'password'
There is no response body.
None
Delete a record from the Incident table.
#Need to install requests package for python
import requests
# Set the request parameters
url = 'https://instance.servicenow.com/api/now/table/incident/d977b66a4f411200adf9f8e18110c7b2'
# Eg. User name="username", Password="password" for this code sample.
user = 'username'
pwd = 'password'
# Set proper headers
headers = {"Accept":"application/json"}
# Do the HTTP request
response = requests.delete(url, auth=(user, pwd), headers=headers)
# Check for HTTP codes other than 204
if response.status_code != 204:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:', response.json())
exit()
# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
There is no response body.
None
Retrieve the first record from the Problem table.
curl "https://instance.servicenow.com/api/now/table/problem?sysparm_limit=1" \
--request GET \
--header "Accept:application/json" \
--user 'username':'password'
The response contains the name-value pairs for the requested record.
{
"result": [
{
"parent": "",
"made_sla": "true",
"watch_list": "",
"upon_reject": "cancel",
"sys_updated_on": "2016-01-19 04:52:04",
"approval_history": "",
"number": "PRB0000050",
"sys_updated_by": "glide.maint",
"opened_by": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/glide.maint",
"value": "glide.maint"
},
"user_input": "",
"sys_created_on": "2016-01-19 04:51:19",
"sys_domain": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/global",
"value": "global"
},
"state": "4",
"sys_created_by": "glide.maint",
"knowledge": "false",
"order": "",
"closed_at": "2016-01-19 04:52:04",
"cmdb_ci": {
"link": "https://instance.servicenow.com/api/now/table/cmdb_ci/55b35562c0a8010e01cff22378e0aea9",
"value": "55b35562c0a8010e01cff22378e0aea9"
},
"delivery_plan": "",
"impact": "3",
"active": "false",
"work_notes_list": "",
"business_service": "",
"priority": "4",
"sys_domain_path": "/",
"time_worked": "",
"expected_start": "",
"rejection_goto": "",
"opened_at": "2016-01-19 04:49:47",
"business_duration": "1970-01-01 00:00:00",
"group_list": "",
"work_end": "",
"approval_set": "",
"wf_activity": "",
"work_notes": "",
"short_description": "Switch occasionally drops connections",
"correlation_display": "",
"delivery_task": "",
"work_start": "",
"assignment_group": "",
"additional_assignee_list": "",
"description": "Switch occasionally drops connections",
"calendar_duration": "1970-01-01 00:02:17",
"close_notes": "updated firmware",
"sys_class_name": "problem",
"closed_by": "",
"follow_up": "",
"sys_id": "04ce72c9c0a8016600b5b7f75ac67b5b",
"contact_type": "phone",
"urgency": "3",
"company": "",
"reassignment_count": "",
"activity_due": "",
"assigned_to": "",
"comments": "",
"approval": "not requested",
"sla_due": "",
"comments_and_work_notes": "",
"due_date": "",
"sys_mod_count": "1",
"sys_tags": "",
"escalation": "0",
"upon_approval": "proceed",
"correlation_id": "",
"location": ""
}
]
}
Retrieve the first record from the Problem table.
#Need to install requests package for python
import requests
# Set the request parameters
url = 'https://instance.servicenow.com/api/now/table/problem?sysparm_limit=1'
# Eg. User name="username", Password="password" for this code sample.
user = 'username'
pwd = 'password'
# Set proper headers
headers = {"Accept":"application/xml"}
# Do the HTTP request
response = requests.get(url, auth=(user, pwd), headers=headers)
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:', response.content)
exit()
# Decode the XML response into a dictionary and use the data
print(response.content)
The response contains the name-value pairs for the requested record.
<?xml version="1.0" encoding="UTF-8"?>
<response>
<result>
<parent />
<made_sla>false</made_sla>
<caused_by />
<watch_list />
<upon_reject />
<sys_updated_on>2016-01-19 20:16:07</sys_updated_on>
<child_incidents />
<hold_reason />
<approval_history />
<number>INC0000001</number>
<resolved_by>
<link>https://instance.servicenow.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441</link>
<value>6816f79cc0a8016401c5a33be04be441</value>
</resolved_by>
<sys_updated_by>admin</sys_updated_by>
<opened_by>
<link>https://instance.servicenow.com/api/now/table/sys_user/681ccaf9c0a8016400b98a06818d57c7</link>
<value>681ccaf9c0a8016400b98a06818d57c7</value>
</opened_by>
<user_input />
<sys_created_on>2014-05-20 18:24:13</sys_created_on>
<sys_domain>
<link>https://instance.servicenow.com/api/now/table/sys_user_group/global</link>
<value>global</value>
</sys_domain>
<state>7</state>
<sys_created_by>pat</sys_created_by>
<knowledge>false</knowledge>
<order />
<calendar_stc>7937181</calendar_stc>
<closed_at>2015-10-20 23:10:06</closed_at>
<cmdb_ci>
<link>https://instance.servicenow.com/api/now/table/cmdb_ci/b0c4030ac0a800090152e7a4564ca36c</link>
<value>b0c4030ac0a800090152e7a4564ca36c</value>
</cmdb_ci>
<delivery_plan />
<impact>1</impact>
<active>false</active>
<work_notes_list />
<business_service />
<priority>1</priority>
<sys_domain_path>/</sys_domain_path>
<rfc />
<time_worked />
<expected_start />
<rejection_goto />
<opened_at>2015-10-19 23:09:51</opened_at>
<business_duration>1970-01-22 21:46:21</business_duration>
<group_list />
<work_end />
<caller_id>
<link>https://instance.servicenow.com/api/now/table/sys_user/5137153cc611227c000bbd1bd8cd2005</link>
<value>5137153cc611227c000bbd1bd8cd2005</value>
</caller_id>
<resolved_at>2016-01-19 19:56:12</resolved_at>
<approval_set />
<subcategory />
<wf_activity />
<work_notes />
<short_description>Can't read email</short_description>
<close_code>Closed/Resolved by Caller</close_code>
<correlation_display />
<delivery_task />
<work_start />
<assignment_group>
<link>https://instance.servicenow.com/api/now/table/sys_user_group/d625dccec0a8016700a222a0f7900d06</link>
<value>d625dccec0a8016700a222a0f7900d06</value>
</assignment_group>
<additional_assignee_list />
<business_stc>1892781</business_stc>
<description>User can't access email on mail.company.com.</description>
<calendar_duration>1970-04-02 20:46:21</calendar_duration>
<close_notes>Closed before close notes were made mandatory</close_notes>
<notify>1</notify>
<sys_class_name>incident</sys_class_name>
<closed_by>
<link>https://instance.servicenow.com/api/now/table/sys_user/9ee1b13dc6112271007f9d0efdb69cd0</link>
<value>9ee1b13dc6112271007f9d0efdb69cd0</value>
</closed_by>
<follow_up />
<parent_incident />
<sys_id>9c573169c611228700193229fff72400</sys_id>
<contact_type />
<incident_state>7</incident_state>
<urgency>1</urgency>
<problem_id>
<link>https://instance.servicenow.com/api/now/table/problem/9d3a266ac6112287004e37fb2ceb0133</link>
<value>9d3a266ac6112287004e37fb2ceb0133</value>
</problem_id>
<company />
<reassignment_count>1</reassignment_count>
<activity_due />
<assigned_to>
<link>https://instance.servicenow.com/api/now/table/sys_user/46b87022a9fe198101a78787e40d7547</link>
<value>46b87022a9fe198101a78787e40d7547</value>
</assigned_to>
<severity>1</severity>
<comments />
<approval />
<sla_due />
<comments_and_work_notes />
<due_date />
<sys_mod_count>21</sys_mod_count>
<reopen_count />
<sys_tags />
<escalation>0</escalation>
<upon_approval />
<correlation_id />
<location>
<link>https://instance.servicenow.com/api/now/table/cmn_location/1083361cc611227501b682158cabf646</link>
<value>1083361cc611227501b682158cabf646</value>
</location>
<category>network</category>
</result>
</response>
Retrieve a record from the Incident table.
curl "https://instance.servicenow.com/api/now/table/incident/a9e30c7dc61122760116894de7bcc7bd" \
--request GET \
--header "Accept:application/json" \
--user 'username':'password'
The response contains the name-value pairs for the requested record.
{
"result": {
"upon_approval": "",
"location": {
"link": "https://instance.servicenow.com/api/now/table/cmn_location/105cf7f3c611227501e75e08b14a38ba",
"value": "105cf7f3c611227501e75e08b14a38ba"
},
"expected_start": "",
"reopen_count": "",
"close_notes": "",
"additional_assignee_list": "",
"impact": "1",
"urgency": "3",
"correlation_id": "",
"sys_tags": "",
"sys_domain": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/global",
"value": "global"
},
"description": "",
"group_list": "",
"priority": "3",
"delivery_plan": "",
"sys_mod_count": "4",
"work_notes_list": "",
"business_service": "",
"follow_up": "",
"closed_at": "",
"sla_due": "2015-11-11 22:04:15",
"delivery_task": "",
"sys_updated_on": "2015-11-01 22:37:27",
"parent": "",
"work_end": "",
"number": "INC0000046",
"closed_by": "",
"work_start": "",
"calendar_stc": "",
"category": "software",
"business_duration": "",
"incident_state": "1",
"activity_due": "",
"correlation_display": "",
"company": "",
"active": "true",
"due_date": "",
"assignment_group": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/8a4dde73c6112278017a6a4baf547aa7",
"value": "8a4dde73c6112278017a6a4baf547aa7"
},
"caller_id": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/46c6f9efa9fe198101ddf5eed9adf6e7",
"value": "46c6f9efa9fe198101ddf5eed9adf6e7"
},
"knowledge": "false",
"made_sla": "false",
"comments_and_work_notes": "",
"parent_incident": "",
"state": "1",
"user_input": "",
"sys_created_on": "2015-11-01 22:05:30",
"approval_set": "",
"reassignment_count": "1",
"rfc": "",
"child_incidents": "",
"opened_at": "2015-11-02 22:04:15",
"short_description": "Can't access SFA software",
"order": "",
"sys_updated_by": "glide.maint",
"resolved_by": "",
"notify": "1",
"upon_reject": "",
"approval_history": "",
"problem_id": {
"link": "https://instance.servicenow.com/api/now/table/problem/a9e4890bc6112276003d7a5a5c774a74",
"value": "a9e4890bc6112276003d7a5a5c774a74"
},
"work_notes": "",
"calendar_duration": "",
"close_code": "",
"sys_id": "a9e30c7dc61122760116894de7bcc7bd",
"approval": "not requested",
"caused_by": "",
"severity": "3",
"sys_created_by": "admin",
"resolved_at": "",
"assigned_to": "",
"business_stc": "",
"wf_activity": "",
"sys_domain_path": "/",
"cmdb_ci": {
"link": "https://instance.servicenow.com/api/now/table/cmdb_ci/a9c0c8d2c6112276018f7705562f9cb0",
"value": "a9c0c8d2c6112276018f7705562f9cb0"
},
"opened_by": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/46c6f9efa9fe198101ddf5eed9adf6e7",
"value": "46c6f9efa9fe198101ddf5eed9adf6e7"
},
"subcategory": "",
"rejection_goto": "",
"sys_class_name": "incident",
"watch_list": "",
"time_worked": "",
"contact_type": "phone",
"escalation": "0",
"comments": ""
}
}
Retrieve the first record from the Incident table.
#Need to install requests package for python
import requests
# Set the request parameters
url = 'https://instance.servicenow.com/api/now/table/incident/a9e30c7dc61122760116894de7bcc7bd'
# Eg. User name="username", Password="password" for this code sample.
user = 'username'
pwd = 'password'
# Set proper headers
headers = {"Accept":"application/xml"}
# Do the HTTP request
response = requests.get(url, auth=(user, pwd), headers=headers)
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:', response.content)
exit()
# Decode the XML response into a dictionary and use the data
print(response.content)
The response contains the name-value pairs for the requested record.
<?xml version="1.0" encoding="UTF-8"?>
<response>
<result>
<upon_approval />
<location>
<link>https://instance.servicenow.com/api/now/table/cmn_location/105cf7f3c611227501e75e08b14a38ba</link>
<value>105cf7f3c611227501e75e08b14a38ba</value>
</location>
<expected_start />
<reopen_count />
<close_notes />
<additional_assignee_list />
<impact>1</impact>
<urgency>3</urgency>
<correlation_id />
<priority>3</priority>
<sys_tags />
<sys_domain>
<link>https://instance.servicenow.com/api/now/table/sys_user_group/global</link>
<value>global</value>
</sys_domain>
<description />
<group_list />
<delivery_plan />
<sys_mod_count>4</sys_mod_count>
<work_notes_list />
<follow_up />
<business_service />
<closed_at />
<sla_due>2015-11-11 22:04:15</sla_due>
<delivery_task />
<sys_updated_on>2015-11-01 22:37:27</sys_updated_on>
<parent />
<work_end />
<number>INC0000046</number>
<closed_by />
<work_start />
<calendar_stc />
<category>software</category>
<business_duration />
<incident_state>1</incident_state>
<activity_due />
<correlation_display />
<company />
<active>true</active>
<due_date />
<assignment_group>
<link>https://instance.servicenow.com/api/now/table/sys_user_group/8a4dde73c6112278017a6a4baf547aa7</link>
<value>8a4dde73c6112278017a6a4baf547aa7</value>
</assignment_group>
<caller_id>
<link>https://instance.servicenow.com/api/now/table/sys_user/46c6f9efa9fe198101ddf5eed9adf6e7</link>
<value>46c6f9efa9fe198101ddf5eed9adf6e7</value>
</caller_id>
<knowledge>false</knowledge>
<made_sla>false</made_sla>
<comments_and_work_notes />
<parent_incident />
<state>1</state>
<user_input />
<sys_created_on>2015-11-01 22:05:30</sys_created_on>
<approval_set />
<reassignment_count>1</reassignment_count>
<rfc />
<opened_at>2015-11-02 22:04:15</opened_at>
<child_incidents />
<order />
<short_description>Can't access SFA software</short_description>
<resolved_by />
<sys_updated_by>glide.maint</sys_updated_by>
<notify>1</notify>
<upon_reject />
<approval_history />
<problem_id>
<link>https://instance.servicenow.com/api/now/table/problem/a9e4890bc6112276003d7a5a5c774a74</link>
<value>a9e4890bc6112276003d7a5a5c774a74</value>
</problem_id>
<calendar_duration />
<work_notes />
<close_code />
<approval>not requested</approval>
<sys_id>a9e30c7dc61122760116894de7bcc7bd</sys_id>
<caused_by />
<severity>3</severity>
<sys_created_by>admin</sys_created_by>
<assigned_to />
<resolved_at />
<business_stc />
<cmdb_ci>
<link>https://instance.servicenow.com/api/now/table/cmdb_ci/a9c0c8d2c6112276018f7705562f9cb0</link>
<value>a9c0c8d2c6112276018f7705562f9cb0</value>
</cmdb_ci>
<sys_domain_path>/</sys_domain_path>
<wf_activity />
<opened_by>
<link>https://instance.servicenow.com/api/now/table/sys_user/46c6f9efa9fe198101ddf5eed9adf6e7</link>
<value>46c6f9efa9fe198101ddf5eed9adf6e7</value>
</opened_by>
<rejection_goto />
<subcategory />
<sys_class_name>incident</sys_class_name>
<watch_list />
<escalation>0</escalation>
<contact_type>phone</contact_type>
<time_worked />
<comments />
</result>
</response>
Update a record in the Incident table.
curl "https://instance.servicenow.com/api/now/table/incident/ef43c6d40a0a0b5700c77f9bf387afe3" \
--request PATCH \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{'assigned_to':'681b365ec0a80164000fb0b05854a0cd','urgency':'1','comments':'Elevating urgency, this is a blocking issue'}" \
--user 'username':'password'
The response contains the name-value pairs for the updated record.
{
"result": {
"upon_approval": "proceed",
"location": {
"link": "https://instance.servicenow.com/api/now/table/cmn_location/108752c8c611227501d4ab0e392ba97f",
"value": "108752c8c611227501d4ab0e392ba97f"
},
"expected_start": "",
"reopen_count": "",
"close_notes": "",
"additional_assignee_list": "",
"impact": "1",
"urgency": "1",
"correlation_id": "",
"sys_tags": "",
"sys_domain": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/global",
"value": "global"
},
"description": "",
"group_list": "",
"priority": "1",
"delivery_plan": "",
"sys_mod_count": "7",
"work_notes_list": "",
"business_service": "",
"follow_up": "",
"closed_at": "",
"sla_due": "2017-07-05 05:58:24",
"delivery_task": "",
"sys_updated_on": "2016-01-22 14:12:37",
"parent": "",
"work_end": "",
"number": "INC0000050",
"closed_by": "",
"work_start": "",
"calendar_stc": "",
"category": "hardware",
"business_duration": "",
"incident_state": "2",
"activity_due": "2016-01-22 16:12:37",
"correlation_display": "",
"company": {
"link": "https://instance.servicenow.com/api/now/table/core_company/31bea3d53790200044e0bfc8bcbe5dec",
"value": "31bea3d53790200044e0bfc8bcbe5dec"
},
"active": "true",
"due_date": "",
"assignment_group": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/8a5055c9c61122780043563ef53438e3",
"value": "8a5055c9c61122780043563ef53438e3"
},
"caller_id": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/5b7c200d0a640069006b3845b5d0fa7c",
"value": "5b7c200d0a640069006b3845b5d0fa7c"
},
"knowledge": "false",
"made_sla": "true",
"comments_and_work_notes": "",
"parent_incident": "",
"state": "2",
"user_input": "",
"sys_created_on": "2015-11-02 18:05:40",
"approval_set": "",
"reassignment_count": "0",
"rfc": "",
"child_incidents": "",
"opened_at": "2015-11-02 21:58:24",
"short_description": "Can't access Exchange server - is it down?",
"order": "",
"sys_updated_by": "admin",
"resolved_by": "",
"notify": "1",
"upon_reject": "cancel",
"approval_history": "",
"problem_id": "",
"work_notes": "",
"calendar_duration": "",
"close_code": "",
"sys_id": "ef43c6d40a0a0b5700c77f9bf387afe3",
"approval": "not requested",
"caused_by": "",
"severity": "3",
"sys_created_by": "glide.maint",
"resolved_at": "",
"assigned_to": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/681b365ec0a80164000fb0b05854a0cd",
"value": "681b365ec0a80164000fb0b05854a0cd"
},
"business_stc": "",
"wf_activity": "",
"sys_domain_path": "/",
"cmdb_ci": {
"link": "https://instance.servicenow.com/api/now/table/cmdb_ci/281190e3c0a8000b003f593aa3f20ca6",
"value": "281190e3c0a8000b003f593aa3f20ca6"
},
"opened_by": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/glide.maint",
"value": "glide.maint"
},
"subcategory": "",
"rejection_goto": "",
"sys_class_name": "incident",
"watch_list": "",
"time_worked": "",
"contact_type": "phone",
"escalation": "3",
"comments": ""
}
}
Update a record in the Incident table.
#Need to install requests package for python
import requests
# Set the request parameters
url = 'https://instance.servicenow.com/api/now/table/incident/ef43c6d40a0a0b5700c77f9bf387afe3'
# Eg. User name="username", Password="password" for this code sample.
user = 'username'
pwd = 'password'
# Set proper headers
headers = {"Content-Type":"application/xml","Accept":"application/xml"}
# Do the HTTP request
response = requests.patch(url, auth=(user, pwd), headers=headers, data="<request><entry><assigned_to>681b365ec0a80164000fb0b05854a0cd</assigned_to><urgency>1</urgency><comments>Elevating urgency, this is a blocking issue</comments></entry></request>")
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:', response.content)
exit()
# Decode the XML response into a dictionary and use the data
print(response.content)
The response contains the name-value pairs for the updated record.
<?xml version="1.0" encoding="UTF-8"?>
<response>
<result>
<upon_approval>proceed</upon_approval>
<location>
<link>https://instance.servicenow.com/api/now/table/cmn_location/108752c8c611227501d4ab0e392ba97f</link>
<value>108752c8c611227501d4ab0e392ba97f</value>
</location>
<expected_start />
<reopen_count />
<close_notes />
<additional_assignee_list />
<impact>1</impact>
<urgency>1</urgency>
<correlation_id />
<priority>1</priority>
<sys_tags />
<sys_domain>
<link>https://instance.servicenow.com/api/now/table/sys_user_group/global</link>
<value>global</value>
</sys_domain>
<description />
<group_list />
<delivery_plan />
<sys_mod_count>8</sys_mod_count>
<work_notes_list />
<follow_up />
<business_service />
<closed_at />
<sla_due>2017-07-05 05:58:24</sla_due>
<delivery_task />
<sys_updated_on>2016-01-22 14:14:54</sys_updated_on>
<parent />
<work_end />
<number>INC0000050</number>
<closed_by />
<work_start />
<calendar_stc />
<category>hardware</category>
<business_duration />
<incident_state>2</incident_state>
<activity_due>2016-01-22 16:14:54</activity_due>
<correlation_display />
<company>
<link>https://instance.servicenow.com/api/now/table/core_company/31bea3d53790200044e0bfc8bcbe5dec</link>
<value>31bea3d53790200044e0bfc8bcbe5dec</value>
</company>
<active>true</active>
<due_date />
<assignment_group>
<link>https://instance.servicenow.com/api/now/table/sys_user_group/8a5055c9c61122780043563ef53438e3</link>
<value>8a5055c9c61122780043563ef53438e3</value>
</assignment_group>
<caller_id>
<link>https://instance.servicenow.com/api/now/table/sys_user/5b7c200d0a640069006b3845b5d0fa7c</link>
<value>5b7c200d0a640069006b3845b5d0fa7c</value>
</caller_id>
<knowledge>false</knowledge>
<made_sla>true</made_sla>
<comments_and_work_notes />
<parent_incident />
<state>2</state>
<user_input />
<sys_created_on>2015-11-02 18:05:40</sys_created_on>
<approval_set />
<reassignment_count>0</reassignment_count>
<rfc />
<opened_at>2015-11-02 21:58:24</opened_at>
<child_incidents />
<order />
<short_description>Can't access Exchange server - is it down?</short_description>
<resolved_by />
<sys_updated_by>admin</sys_updated_by>
<notify>1</notify>
<upon_reject>cancel</upon_reject>
<approval_history />
<problem_id />
<calendar_duration />
<work_notes />
<close_code />
<approval>not requested</approval>
<sys_id>ef43c6d40a0a0b5700c77f9bf387afe3</sys_id>
<caused_by />
<severity>3</severity>
<sys_created_by>glide.maint</sys_created_by>
<assigned_to>
<link>https://instance.servicenow.com/api/now/table/sys_user/681b365ec0a80164000fb0b05854a0cd</link>
<value>681b365ec0a80164000fb0b05854a0cd</value>
</assigned_to>
<resolved_at />
<business_stc />
<cmdb_ci>
<link>https://instance.servicenow.com/api/now/table/cmdb_ci/281190e3c0a8000b003f593aa3f20ca6</link>
<value>281190e3c0a8000b003f593aa3f20ca6</value>
</cmdb_ci>
<sys_domain_path>/</sys_domain_path>
<wf_activity />
<opened_by>
<link>https://instance.servicenow.com/api/now/table/sys_user/glide.maint</link>
<value>glide.maint</value>
</opened_by>
<rejection_goto />
<subcategory />
<sys_class_name>incident</sys_class_name>
<watch_list />
<escalation>3</escalation>
<contact_type>phone</contact_type>
<time_worked />
<comments />
</result>
</response>
Insert a new record into the Incident table.
curl "https://instance.servicenow.com/api/now/table/incident" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{'short_description':'Unable to connect to office wifi','assignment_group':'287ebd7da9fe198100f92cc8d1d2154e','urgency':'2','impact':'2'}" \
--user 'username':'password'
The response contains the name-value pairs for the new record.
{
"result": {
"upon_approval": "proceed",
"location": "",
"expected_start": "",
"reopen_count": "0",
"close_notes": "",
"additional_assignee_list": "",
"impact": "2",
"urgency": "2",
"correlation_id": "",
"sys_tags": "",
"sys_domain": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/global",
"value": "global"
},
"description": "",
"group_list": "",
"priority": "3",
"delivery_plan": "",
"sys_mod_count": "0",
"work_notes_list": "",
"business_service": "",
"follow_up": "",
"closed_at": "",
"sla_due": "",
"delivery_task": "",
"sys_updated_on": "2016-01-22 14:28:24",
"parent": "",
"work_end": "",
"number": "INC0010002",
"closed_by": "",
"work_start": "",
"calendar_stc": "",
"category": "inquiry",
"business_duration": "",
"incident_state": "1",
"activity_due": "",
"correlation_display": "",
"company": "",
"active": "true",
"due_date": "",
"assignment_group": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/287ebd7da9fe198100f92cc8d1d2154e",
"value": "287ebd7da9fe198100f92cc8d1d2154e"
},
"caller_id": "",
"knowledge": "false",
"made_sla": "true",
"comments_and_work_notes": "",
"parent_incident": "",
"state": "1",
"user_input": "",
"sys_created_on": "2016-01-22 14:28:24",
"approval_set": "",
"reassignment_count": "0",
"rfc": "",
"child_incidents": "0",
"opened_at": "2016-01-22 14:28:24",
"short_description": "Unable to connect to office wifi",
"order": "",
"sys_updated_by": "admin",
"resolved_by": "",
"notify": "1",
"upon_reject": "cancel",
"approval_history": "",
"problem_id": "",
"work_notes": "",
"calendar_duration": "",
"close_code": "",
"sys_id": "c537bae64f411200adf9f8e18110c76e",
"approval": "not requested",
"caused_by": "",
"severity": "3",
"sys_created_by": "admin",
"resolved_at": "",
"assigned_to": "",
"business_stc": "",
"wf_activity": "",
"sys_domain_path": "/",
"cmdb_ci": "",
"opened_by": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441",
"value": "6816f79cc0a8016401c5a33be04be441"
},
"subcategory": "",
"rejection_goto": "",
"sys_class_name": "incident",
"watch_list": "",
"time_worked": "",
"contact_type": "phone",
"escalation": "0",
"comments": ""
}
}
Insert a new record into the Incident table.
#Need to install requests package for python
import requests
# Set the request parameters
url = 'https://instance.servicenow.com/api/now/table/incident'
# Eg. User name="username", Password="password" for this code sample.
user = 'username'
pwd = 'password'
# Set proper headers
headers = {"Content-Type":"application/xml","Accept":"application/json"}
# Do the HTTP request
response = requests.post(url, auth=(user, pwd), headers=headers, data="<request><entry><short_description>Unable to connect to office wifi</short_description><assignment_group>287ebd7da9fe198100f92cc8d1d2154e</assignment_group><urgency>2</urgency><impact>2</impact></entry></request>")
# Check for HTTP codes other than 201
if response.status_code != 201:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:', response.json())
exit()
# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
The response contains the name-value pairs for the new record.
{
"result": {
"upon_approval": "proceed",
"location": "",
"expected_start": "",
"reopen_count": "0",
"close_notes": "",
"additional_assignee_list": "",
"impact": "2",
"urgency": "2",
"correlation_id": "",
"sys_tags": "",
"sys_domain": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/global",
"value": "global"
},
"description": "",
"group_list": "",
"priority": "3",
"delivery_plan": "",
"sys_mod_count": "0",
"work_notes_list": "",
"business_service": "",
"follow_up": "",
"closed_at": "",
"sla_due": "",
"delivery_task": "",
"sys_updated_on": "2016-01-22 14:28:24",
"parent": "",
"work_end": "",
"number": "INC0010002",
"closed_by": "",
"work_start": "",
"calendar_stc": "",
"category": "inquiry",
"business_duration": "",
"incident_state": "1",
"activity_due": "",
"correlation_display": "",
"company": "",
"active": "true",
"due_date": "",
"assignment_group": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/287ebd7da9fe198100f92cc8d1d2154e",
"value": "287ebd7da9fe198100f92cc8d1d2154e"
},
"caller_id": "",
"knowledge": "false",
"made_sla": "true",
"comments_and_work_notes": "",
"parent_incident": "",
"state": "1",
"user_input": "",
"sys_created_on": "2016-01-22 14:28:24",
"approval_set": "",
"reassignment_count": "0",
"rfc": "",
"child_incidents": "0",
"opened_at": "2016-01-22 14:28:24",
"short_description": "Unable to connect to office wifi",
"order": "",
"sys_updated_by": "admin",
"resolved_by": "",
"notify": "1",
"upon_reject": "cancel",
"approval_history": "",
"problem_id": "",
"work_notes": "",
"calendar_duration": "",
"close_code": "",
"sys_id": "c537bae64f411200adf9f8e18110c76e",
"approval": "not requested",
"caused_by": "",
"severity": "3",
"sys_created_by": "admin",
"resolved_at": "",
"assigned_to": "",
"business_stc": "",
"wf_activity": "",
"sys_domain_path": "/",
"cmdb_ci": "",
"opened_by": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441",
"value": "6816f79cc0a8016401c5a33be04be441"
},
"subcategory": "",
"rejection_goto": "",
"sys_class_name": "incident",
"watch_list": "",
"time_worked": "",
"contact_type": "phone",
"escalation": "0",
"comments": ""
}
}
Update a record in the Incident table.
curl "https://instance.servicenow.com/api/now/table/incident/ef43c6d40a0a0b5700c77f9bf387afe3" \
--request PUT \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{'assigned_to':'681b365ec0a80164000fb0b05854a0cd','urgency':'1','comments':'Elevating urgency, this is a blocking issue'}" \
--user 'username':'password'
The response contains the name-value pairs for the updated record.
{
"result": {
"upon_approval": "proceed",
"location": {
"link": "https://instance.servicenow.com/api/now/table/cmn_location/108752c8c611227501d4ab0e392ba97f",
"value": "108752c8c611227501d4ab0e392ba97f"
},
"expected_start": "",
"reopen_count": "",
"close_notes": "",
"additional_assignee_list": "",
"impact": "1",
"urgency": "1",
"correlation_id": "",
"sys_tags": "",
"sys_domain": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/global",
"value": "global"
},
"description": "",
"group_list": "",
"priority": "1",
"delivery_plan": "",
"sys_mod_count": "7",
"work_notes_list": "",
"business_service": "",
"follow_up": "",
"closed_at": "",
"sla_due": "2017-07-05 05:58:24",
"delivery_task": "",
"sys_updated_on": "2016-01-22 14:12:37",
"parent": "",
"work_end": "",
"number": "INC0000050",
"closed_by": "",
"work_start": "",
"calendar_stc": "",
"category": "hardware",
"business_duration": "",
"incident_state": "2",
"activity_due": "2016-01-22 16:12:37",
"correlation_display": "",
"company": {
"link": "https://instance.servicenow.com/api/now/table/core_company/31bea3d53790200044e0bfc8bcbe5dec",
"value": "31bea3d53790200044e0bfc8bcbe5dec"
},
"active": "true",
"due_date": "",
"assignment_group": {
"link": "https://instance.servicenow.com/api/now/table/sys_user_group/8a5055c9c61122780043563ef53438e3",
"value": "8a5055c9c61122780043563ef53438e3"
},
"caller_id": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/5b7c200d0a640069006b3845b5d0fa7c",
"value": "5b7c200d0a640069006b3845b5d0fa7c"
},
"knowledge": "false",
"made_sla": "true",
"comments_and_work_notes": "",
"parent_incident": "",
"state": "2",
"user_input": "",
"sys_created_on": "2015-11-02 18:05:40",
"approval_set": "",
"reassignment_count": "0",
"rfc": "",
"child_incidents": "",
"opened_at": "2015-11-02 21:58:24",
"short_description": "Can't access Exchange server - is it down?",
"order": "",
"sys_updated_by": "admin",
"resolved_by": "",
"notify": "1",
"upon_reject": "cancel",
"approval_history": "",
"problem_id": "",
"work_notes": "",
"calendar_duration": "",
"close_code": "",
"sys_id": "ef43c6d40a0a0b5700c77f9bf387afe3",
"approval": "not requested",
"caused_by": "",
"severity": "3",
"sys_created_by": "glide.maint",
"resolved_at": "",
"assigned_to": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/681b365ec0a80164000fb0b05854a0cd",
"value": "681b365ec0a80164000fb0b05854a0cd"
},
"business_stc": "",
"wf_activity": "",
"sys_domain_path": "/",
"cmdb_ci": {
"link": "https://instance.servicenow.com/api/now/table/cmdb_ci/281190e3c0a8000b003f593aa3f20ca6",
"value": "281190e3c0a8000b003f593aa3f20ca6"
},
"opened_by": {
"link": "https://instance.servicenow.com/api/now/table/sys_user/glide.maint",
"value": "glide.maint"
},
"subcategory": "",
"rejection_goto": "",
"sys_class_name": "incident",
"watch_list": "",
"time_worked": "",
"contact_type": "phone",
"escalation": "3",
"comments": ""
}
}
Update a record in the Incident table.
#Need to install requests package for python
import requests
# Set the request parameters
url = 'https://instance.servicenow.com/api/now/table/incident/ef43c6d40a0a0b5700c77f9bf387afe3'
# Eg. User name="username", Password="password" for this code sample.
user = 'username'
pwd = 'password'
# Set proper headers
headers = {"Content-Type":"application/xml","Accept":"application/xml"}
# Do the HTTP request
response = requests.put(url, auth=(user, pwd), headers=headers, data="<request><entry><assigned_to>681b365ec0a80164000fb0b05854a0cd</assigned_to><urgency>1</urgency><comments>Elevating urgency, this is a blocking issue</comments></entry></request>")
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:', response.content)
exit()
# Decode the XML response into a dictionary and use the data
print(response.content)
The response contains the name-value pairs for the updated record.
<?xml version="1.0" encoding="UTF-8"?>
<response>
<result>
<upon_approval>proceed</upon_approval>
<location>
<link>https://instance.servicenow.com/api/now/table/cmn_location/108752c8c611227501d4ab0e392ba97f</link>
<value>108752c8c611227501d4ab0e392ba97f</value>
</location>
<expected_start />
<reopen_count />
<close_notes />
<additional_assignee_list />
<impact>1</impact>
<urgency>1</urgency>
<correlation_id />
<priority>1</priority>
<sys_tags />
<sys_domain>
<link>https://instance.servicenow.com/api/now/table/sys_user_group/global</link>
<value>global</value>
</sys_domain>
<description />
<group_list />
<delivery_plan />
<sys_mod_count>8</sys_mod_count>
<work_notes_list />
<follow_up />
<business_service />
<closed_at />
<sla_due>2017-07-05 05:58:24</sla_due>
<delivery_task />
<sys_updated_on>2016-01-22 14:14:54</sys_updated_on>
<parent />
<work_end />
<number>INC0000050</number>
<closed_by />
<work_start />
<calendar_stc />
<category>hardware</category>
<business_duration />
<incident_state>2</incident_state>
<activity_due>2016-01-22 16:14:54</activity_due>
<correlation_display />
<company>
<link>https://instance.servicenow.com/api/now/table/core_company/31bea3d53790200044e0bfc8bcbe5dec</link>
<value>31bea3d53790200044e0bfc8bcbe5dec</value>
</company>
<active>true</active>
<due_date />
<assignment_group>
<link>https://instance.servicenow.com/api/now/table/sys_user_group/8a5055c9c61122780043563ef53438e3</link>
<value>8a5055c9c61122780043563ef53438e3</value>
</assignment_group>
<caller_id>
<link>https://instance.servicenow.com/api/now/table/sys_user/5b7c200d0a640069006b3845b5d0fa7c</link>
<value>5b7c200d0a640069006b3845b5d0fa7c</value>
</caller_id>
<knowledge>false</knowledge>
<made_sla>true</made_sla>
<comments_and_work_notes />
<parent_incident />
<state>2</state>
<user_input />
<sys_created_on>2015-11-02 18:05:40</sys_created_on>
<approval_set />
<reassignment_count>0</reassignment_count>
<rfc />
<opened_at>2015-11-02 21:58:24</opened_at>
<child_incidents />
<order />
<short_description>Can't access Exchange server - is it down?</short_description>
<resolved_by />
<sys_updated_by>admin</sys_updated_by>
<notify>1</notify>
<upon_reject>cancel</upon_reject>
<approval_history />
<problem_id />
<calendar_duration />
<work_notes />
<close_code />
<approval>not requested</approval>
<sys_id>ef43c6d40a0a0b5700c77f9bf387afe3</sys_id>
<caused_by />
<severity>3</severity>
<sys_created_by>glide.maint</sys_created_by>
<assigned_to>
<link>https://instance.servicenow.com/api/now/table/sys_user/681b365ec0a80164000fb0b05854a0cd</link>
<value>681b365ec0a80164000fb0b05854a0cd</value>
</assigned_to>
<resolved_at />
<business_stc />
<cmdb_ci>
<link>https://instance.servicenow.com/api/now/table/cmdb_ci/281190e3c0a8000b003f593aa3f20ca6</link>
<value>281190e3c0a8000b003f593aa3f20ca6</value>
</cmdb_ci>
<sys_domain_path>/</sys_domain_path>
<wf_activity />
<opened_by>
<link>https://instance.servicenow.com/api/now/table/sys_user/glide.maint</link>
<value>glide.maint</value>
</opened_by>
<rejection_goto />
<subcategory />
<sys_class_name>incident</sys_class_name>
<watch_list />
<escalation>3</escalation>
<contact_type>phone</contact_type>
<time_worked />
<comments />
</result>
</response>
curl "https://instance.servicenow.com/api/sn_km_api/knowledge/articles?query=Windows&limit=2&fields=short_description&fields=sys_class_name" \
--request GET \
--header "Accept:application/xml" \
--user "username":"password"
Articles
References
Projects