JSON Data Modification API
Summarize
Summary of JSON Data Modification API
The JSON Data Modification API enables ServiceNow customers to modify data on their instance by sending HTTPS POST requests with JSON payloads. This API supports key actions such as creating, updating, and deleting records via JSON objects sent to the instance URL. It requires thesysparmactionparameter to specify the desired operation and expects the content type to beapplication/json.
Show less
Key Features
- Insert: Create a single new record by posting a JSON object with field values. The response returns the created record as JSON. The
sysparmactioncan be included in the URL or inside the JSON payload, with the JSON parameter taking precedence. - InsertMultiple: Create multiple records by posting a JSON object containing an array of records under the
recordsfield. The response includes all created records. - Update: Update one or more records filtered by an encoded query string specified in the
sysparmqueryURL parameter. The JSON payload contains the fields and values to update. The response includes an array of updated records. - DeleteRecord: Delete a single record identified by the
sysparmsysidparameter, which can be passed either in the JSON payload or as a URL parameter. - DeleteMultiple: Delete multiple records filtered by a query string specified in the
sysparmqueryURL parameter or within the JSON payload.
Practical Use for ServiceNow Customers
This API enables automated and programmatic data manipulation directly on ServiceNow tables using JSON, facilitating integration with scripts, external applications, or automation workflows. By leveraging these actions, customers can efficiently manage records—creating incidents, updating multiple records in bulk, or deleting records based on specific criteria—all through standard HTTPS POST requests with JSON content. This approach helps streamline data operations while maintaining precise control over record handling on their instance.
Modify data using the JSON web service by sending an HTTPS POST request to the instance.
sysparm_action
parameter to indicate the type of action to be performed, with the incoming JSON object post in
the body.insert
Create a new record in ServiceNow. The JSON object has to be POSTed as the body (content-type is usually application/json, although not enforced). The response from the record creation is a JSON object of the incident that was created.
{"short_description":"this is a test","priority":"1"}https://your_instance.service-now.com/incident.do?JSONv2&sysparm_action=insertcreates an incident.
{"sysparm_action":"insert","short_description":"this is a test","priority":"1"}insertMultiple
{ "records" : [ { "short_description" : "this was inserted with python using JSON 1" , "priority" : "1 - Critical" , "impact" : "1" , "caller_id" : "Fred Luddy" } , { "short_description" : "this was inserted with python using JSON 2" , "priority" : "1 - Critical" , "impact" : "1" , "caller_id" : "Fred Luddy" } ] }https://<instance name>.service-now.com/incident.do?JSONv2&sysparm_action=insert
https://<instance name>.service-now.com/incident.do?JSONv2&sysparm_action=insertMultiple
creates two incidents. Note the fields described as an array value for the records field.
update
Update a record or a list of records filtered by an
encoded query string
specified by the
sysparm_query
URL parameter. The JSON object has to be posted as the body (content-type is usually
application/json, although not enforced). The response from the record creation is an array of
JSON objects representing the records that were updated.
{"short_description":"this was updated with python", "priority": "3", "impact":"1"}https://instance_name.service-now.com/incident.do?JSONv2&sysparm_query=priority=3&sysparm_action=update
updates all incidents with priority 3, and sets the values specified by the JSON object.
deleteRecord
Delete a single record from the targeted table, identified by a
sysparm_sys_id
parameter. The parameter may be encoded in the input JSON object or given as a URL
parameter.
{"sysparm_sys_id":"fd4001f80a0a0b380032ffa2b749927b"}
http://instance_name.service-now.com/incident.do?JSONv2&sysparm_action=deleteRecord
deletes the incident record identified by the sys_id fd4001f80a0a0b380032ffa2b749927b.
deleteMultiple
Delete multiple records from the targeted table, filtered by an
encoded query string
specified in the
sysparm_query
URL parameter. The filter may also be encoded in the input JSON object.
{"sysparm_query":"short_description=this was updated with python"}http://instance_name.service-now.com/incident.do?JSONv2&sysparm_action=deleteMultipledeletes all incident records where the short_description field contains the
value "this was updated with python".