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 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
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 4. 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.

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"
    }
  ]
}

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>