Import Set API Examples

Use POST to import data to your instance and GET methods to query import set data.

POST Examples

Table 1. Loading a record to an import set
Request:
 $ curl http://https://<instance name>.service-now.com/api/now/import/imp_notification -XPOST --user admin:admin
 -H "Accept: application/json" -H "Content-Type: application/json" --data
 '{"message":"some message", "uuid":"00004"}' -v<br>
 > POST /api/now/import/imp_notification HTTP/1.1
 > Authorization: Basic YWRtaW46YWRtaW4=
 > Accept: application/json
 > Content-Type: application/json
 >

Response:

 < HTTP/1.1 201 Created
 < Location:
 http://https://<instance name>.service-now.com/api/now/import/imp_notification/127375019f23110041a496fcc67fcfe3
 < Content-Type: application/json
 <
 {
 "result": [
 {
 "sys_id": "567375019f23110041a496fcc67fcfe3",
 "status": "inserted",
 "record_link":
 "https://<instance name>.service-now.com/api/now/table/incident/567375019f23110041a496fcc67fcfe3",
 "display_value": "INC0010023",
 "display_name": "number",
 "table": "incident",
 "transform_map": "Notification"
 }
 ],
 "staging_table": "imp_notification",
 "import_set": "ISET0010004"
 }
Table 2. Results for multiple targets are returned
Request:
 $ curl http://https://<instance name>.service-now.com/api/now/import/imp_notification -XPOST --user admin:admin
 -H "Accept: application/json" -H "Content-Type: application/json" --data
 '{"message":"some message", "uuid":"00005"}' -v
 > POST /api/now/import/imp_notification HTTP/1.1
 > Authorization: Basic YWRtaW46YWRtaW4=
 > Authorization: Basic YWRtaW46YWRtaW4=
 > Accept: application/json
 > Content-Type: application/json
 >

Response:

 < HTTP/1.1 201 Created
 < Location:
 http://https://<instance name>.service-now.com/api/now/import/imp_notification/404875019f23110041a496fcc67fcfe5
 {
 "result": [
 {
 "sys_id": "484875019f23110041a496fcc67fcfe5",
 "status": "inserted",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/incident/484875019f23110041a496fcc67fcfe5",
 "display_value": "INC0010024",
 "display_name": "number",
 "table": "incident",
 "transform_map": "Notification"
 },
 {
 "sys_id": "084875019f23110041a496fcc67fcfe6",
 "status": "inserted",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/problem/084875019f23110041a496fcc67fcfe6",
 "display_value": "PRB0040025",
 "display_name": "number",
 "table": "problem",
 "transform_map": "Problem Xform"
 }
 ],
 "staging_table": "imp_notification",
 "import_set": "ISET0010004"
 }
Table 3. Using a simple transform script defined on Problem Xform
Predefined Transform Script:
 status_message = "I’m a status message";

Request:

 $ curl http://https://<instance name>.service-now.com/api/now/import/imp_notification -XPOST --user admin:admin
 -H "Accept: application/json" -H "Content-Type: application/json" --data
 '{"message":"some message", "uuid":"00006"}' -v
 > POST /api/now/import/imp_notification HTTP/1.1
 > Authorization: Basic YWRtaW46YWRtaW4=
 > Accept: application/json
 > Content-Type: application/json
 >

Response:

 < HTTP/1.1 201 Created
 < Location:
 http://https://<instance name>.service-now.com/api/now/import/imp_notification/922975019f23110041a496fcc67fcf6a
 {
 "result": [
 {
 "sys_id": "5a2975019f23110041a496fcc67fcf6a",
 "status": "inserted",
 "record_link":
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/incident/5a2975019f23110041a496fcc67fcf6a",
 "display_value": "INC0010025",
 "display_name": "number",
 "table": "incident",
 "transform_map": "Notification"
 },
 {
 "status_message": "I'm a status message", <<<———————————— status message
 "sys_id": "1a2975019f23110041a496fcc67fcf6b",
 "status": "inserted",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/problem/1a2975019f23110041a496fcc67fcf6b",
 "display_value": "PRB0040026",
 "display_name": "number",
 "table": "problem",
 "transform_map": "Problem Xform"
 }
 ],
 "staging_table": "imp_notification",
 "import_set": "ISET0010004"
 }
Table 4. Using a script to define custom dynamic fields
Script to Define Custom Fields:
 status_message = "I’m a status message";
 response.comments = "Comments field";
 response.another_field = "Another field";

Request:

$ curl http://https://<instance name>.service-now.com/api/now/import/imp_notification -XPOST --user admin:admin
-H "Accept: application/json" -H "Content-Type: application/json" --data
'{"message":"some message", "uuid":"00007"}' -v
> POST /api/now/import/imp_notification HTTP/1.1
> Authorization: Basic YWRtaW46YWRtaW4=
> Accept: application/json
> Content-Type: application/json
></pre>

Response:

 < HTTP/1.1 201 Created
 < Location:
 http://https://<instance name>.service-now.com/api/now/import/imp_notification/49fa75019f23110041a496fcc67fcfe7
 {
 "result": [
 {
 "sys_id": "01fa75019f23110041a496fcc67fcfe8",
 "status": "inserted",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/incident/01fa75019f23110041a496fcc67fcfe8",
 "display_value": "INC0010026",
 "display_name": "number",
 "table": "incident",
 "transform_map": "Notification"
 },
 {
 "comments": "Comments field",
 "status_message": "I'm a status message",
 "transform_map": "Problem Xform",
 "table": "problem",
 "display_name": "number",
 "display_name": "number",
 "display_value": "PRB0040027",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/problem/cdfa75019f23110041a496fcc67fcfe8",
 "status": "inserted",
 "sys_id": "cdfa75019f23110041a496fcc67fcfe8",
 "another_field": "Another field"
 }
 ],
 "staging_table": "imp_notification",
 "import_set": "ISET0010004"
 }
Table 5. No update due to coalesce and no data change
Request:
 $ curl http://https://<instance name>.service-now.com/api/now/import/imp_notification -XPOST --user admin:admin
 -H "Accept: application/json" -H "Content-Type: application/json" --data
 '{"message":"some message", "uuid":"00007"}' -v
 > POST /api/now/import/imp_notification HTTP/1.1
 > Authorization: Basic YWRtaW46YWRtaW4=
 > Accept: application/json
 > Content-Type: application/json
 >

Response:

 < Location:
 http://https://<instance name>.service-now.com/api/now/import/imp_notification/e82d75019f23110041a496fcc67fcf6c
 {
 "result": [
 {
 "comments": "Comments field",
 "status_message": "I'm a status message;No field values changed",
 "transform_map": "Problem Xform",
 "table": "problem",
 "display_name": "number",
 "display_value": "PRB0040027",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/problem/cdfa75019f23110041a496fcc67fcfe8",
 "status": "ignored",
 "sys_id": "cdfa75019f23110041a496fcc67fcfe8",
 "another_field": "Another field"
 },
 {
 "status_message": "No field values changed",
 "sys_id": "01fa75019f23110041a496fcc67fcfe8",
 "status": "ignored",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/incident/01fa75019f23110041a496fcc67fcfe8",
 "display_value": "INC0010026",
 "display_name": "number",
 "table": "incident",
 "transform_map": "Notification"
 }
 ],
 "staging_table": "imp_notification",
 "import_set": "ISET0010004"
 }
Table 6. Record updated
Request:
 $ curl http://https://<instance name>.service-now.com/api/now/import/imp_notification -XPOST --user admin:admin
 -H "Accept: application/json" -H "Content-Type: application/json" --data
 '{"message":"some message data changed", "uuid":"00007"}' -v
 > POST /api/now/import/imp_notification HTTP/1.1
 > Authorization: Basic YWRtaW46YWRtaW4=
 > Accept: application/json
 > Content-Type: application/json
 >

Response:

 < HTTP/1.1 201 Created
 < Location: 
 http://https://<instance name>.service-now.com/api/now/import/imp_notification/dedd75019f23110041a496fcc67fcfe9
 {
 "result": [
 {
 "comments": "Comments field",
 "status_message": "I'm a status message;No field values changed",
 "transform_map": "Problem Xform",
 "table": "problem",
 "display_name": "number",
 "display_value": "PRB0040027",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/problem/cdfa75019f23110041a496fcc67fcfe8",
 "status": "ignored",
 "sys_id": "cdfa75019f23110041a496fcc67fcfe8",
 "another_field": "Another field"
 },
 {
 "sys_id": "01fa75019f23110041a496fcc67fcfe8",
 "status": "updated",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/incident/01fa75019f23110041a496fcc67fcfe8",
 "display_value": "INC0010026",
 "display_name": "number",
 "table": "incident",
 "transform_map": "Notification"
 }
 ],
 "staging_table": "imp_notification",
 "import_set": "ISET0010004"
 }

GET Examples

Table 7. Getting the results again using the Location header link
Request:
  $ curl
 http://https://<instance name>.service-now.com/api/now/import/imp_notification/127375019f23110041a496fcc67fcfe3
 -XGET --user admin:admin -H "Accept: application/json" -v<br>
 > GET /api/now/import/imp_notification/127375019f23110041a496fcc67fcfe3 HTTP/1.1
 > Authorization: Basic YWRtaW46YWRtaW4=
 > Accept: application/json
 >

Response:

 < HTTP/1.1 200 OK
 <
 {
 "result": [
 {
 "sys_id": "567375019f23110041a496fcc67fcfe3",
 "status": "inserted",
 "record_link":
 "http://https://<instance name>.service-now.com/api/now/table/incident/567375019f23110041a496fcc67fcfe3",
 "display_value": "INC0010023",
 "display_name": "number",
 "table": "incident",
 "table": "incident",
 "transform_map": "Notification"
 }
 ],
 "staging_table": "imp_notification",
 "import_set": "ISET0010004"
 }