Thank you for your feedback.
Form temporarily unavailable. Please try again or contact docfeedback@servicenow.com to submit your comments.
Versions
  • Madrid
  • London
  • Kingston
  • Jakarta
  • Istanbul
  • Helsinki
  • Geneva
  • Store
Close

Import Set API

Log in to subscribe to topics and get notified when content changes.

Import Set API

The Import Set API allows you to interact with import set tables.

Overview

The API transforms incoming data based on associated transform maps. The import set API supports synchronous transforms. The Import Set API mirrors the existing SOAP interface.

Security

Access to tables via the REST API is restricted by BasicAuth. To allow access to tables without any authentication or authorization, add the table name to sys_public.list. ACLs defined on tables are still enforced, and it is the administrator's responsibility to deactivate ACLs.

Import Set API - GET /now/import/{tableName}/{sys_id}

This method retrieves the specified import staging record and resulting transformation result.

URL format

Versioned URL: /api/now/v1/import/{tableName}/{sys_id}

Default URL: /api/now/import/{tableName}/{sys_id}

Supported request parameters

Table 1. Parameters
Parameter Description
None

Headers

The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.

Table 2. Request headers
Header Description
None
Table 3. Response headers
Header Description
None

Status codes

The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST response codes .

Table 4. Status codes
Status code Description
200 Indicates the query ran successfully.
404 Indicates the specified resource was not available. As import set tables are deleted frequently based on a schedule, GET requests may return 404 NotFound responses if the transformation result no longer exists.

Example: Sample cURL request

curl "https://instance.service-now.com/api/now/import/imp_user/e2928be64f411200adf9f8e18110c777" \
--request GET \
--header "Accept:application/json" \
--user 'admin':'admin'
{
  "import_set": "ISET0010001",
  "staging_table": "imp_user",
  "result": [
    {
      "transform_map": "User",
      "table": "sys_user",
      "display_name": "name",
      "display_value": "John Public",
      "record_link": "https://instance.service-now.com/api/now/table/sys_user/ea928be64f411200adf9f8e18110c777",
      "status": "inserted",
      "sys_id": "ea928be64f411200adf9f8e18110c777"
    }
  ]
}

Example: Sample Python request

#Need to install requests package for python
#easy_install requests
import requests

# Set the request parameters
url = 'https://instance.service-now.com/api/now/import/imp_user/e2928be64f411200adf9f8e18110c777'

# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'

# Set proper headers
headers = {"Content-Type":"application/xml","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.json())
    exit()

# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
<?xml version="1.0" encoding="UTF-8"?>
<response>
   <import_set>ISET0010001</import_set>
   <staging_table>imp_user</staging_table>
   <result>
      <display_name>name</display_name>
      <display_value>John Public</display_value>
      <status>inserted</status>
      <sys_id>ea928be64f411200adf9f8e18110c777</sys_id>
      <record_link>https://instance.service-now.com/api/now/table/sys_user/ea928be64f411200adf9f8e18110c777</record_link>
      <table>sys_user</table>
      <transform_map>User</transform_map>
   </result>
</response>

Import Set API - POST /now/import/{tableName}

This method inserts incoming data into a specified staging table and triggers transformation based on predefined transform maps in the import set table.

URL format

Versioned URL: /api/now/v1/import/<staging table_name>

Default URL: /api/now/import/<staging table_name>

Supported request parameters

Table 5. Parameters
Parameter Description
None

Headers

The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.

Table 6. Request headers
Header Description
None
Table 7. Response headers
Header Description
Location The URL of the created resource.

Status codes

The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST response codes .

Table 8. Status codes
Status code Description
201 Indicates the import completed successfully.

Transforming inserted records

Transformation occurs synchronously. For each transform map that you define, the responses include transformation results such as information on the target records.
Note: The status_message and error_message fields on transformation scripts are processed and returned in response, along with any custom response fields.

Example: Sample cURL request

curl "https://instance.service-now.com/api/now/import/imp_user" \
--request POST \
--header "Accept:application/json"\
--header "Content-Type:application/json" \
--data "{'first_name':'John','last_name':'Public','user_id':'john.public','email':'john.public@company.com'}" \
--user 'admin':'admin'
{
  "import_set": "ISET0010001",
  "staging_table": "imp_user",
  "result": [
    {
      "transform_map": "User",
      "table": "sys_user",
      "display_name": "name",
      "display_value": "John Public",
      "record_link": "https://instance.service-now.com/api/now/table/sys_user/ea928be64f411200adf9f8e18110c777",
      "status": "inserted",
      "sys_id": "ea928be64f411200adf9f8e18110c777"
    }
  ]
}

Example: Sample Python request

#Need to install requests package for python
#easy_install requests
import requests

# Set the request parameters
url = 'https://instance.service-now.com/api/now/import/imp_user'

# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'

# Set proper headers
headers = {"Content-Type":"application/xml","Accept":"application/xml"}

# Do the HTTP request
response = requests.post(url, auth=(user, pwd), headers=headers ,data=" <request><entry><first_name>John</first_name><last_name>Public</last_name><user_id>john.public</user_id><email>john.public@company.com</email></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.json())
    exit()

# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
<?xml version="1.0" encoding="UTF-8"?>
<response>
   <import_set>ISET0010001</import_set>
   <staging_table>imp_user</staging_table>
   <result>
      <display_name>name</display_name>
      <display_value>John Public</display_value>
      <status>ignored</status>
      <status_message>No field values changed</status_message>
      <sys_id>ea928be64f411200adf9f8e18110c777</sys_id>
      <record_link>https://instance.service-now.com/api/now/table/sys_user/ea928be64f411200adf9f8e18110c777</record_link>
      <table>sys_user</table>
      <transform_map>User</transform_map>
   </result>
</response>
Feedback