We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

import set to load data

Ketan Pandey
Tera Expert

Can external API call the Import Set to load the data into servicenow .If yes please suggest how to do this

3 REPLIES 3

cloudops
Tera Expert

Yes, external APIs can call the Import Set to load data into ServiceNow. Here are the steps to do this:

1. **Create an Import Set Table**: Navigate to System Import Sets > Create New Table. This table will hold the data you're importing.

2. **Create Transform Map**: Navigate to System Import Sets > Transform Maps. This map will define how the data in your import set table is transformed into ServiceNow format.

3. **Create a REST API Endpoint**: Navigate to System Web Services > REST > REST API. This endpoint will allow external systems to send data to your import set table.

4. **Define the API Method**: In the REST API record, define a POST method. This method should include a script that inserts the incoming data into the import set table.

5. **Call the API from External System**: From your external system, make a POST request to the API endpoint you created. The body of the request should contain the data you want to import.

6. **Run Transform Map**: After the data is in the import set table, run the transform map to move the data into the appropriate ServiceNow table.

Here is a sample code for the API method:

javascript
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

// parse the request body
var data = request.body.data;

// insert data into import set table
var importSetTable = new GlideRecord('your_import_set_table');
for (var i = 0; i < data.length; i++) {
importSetTable.initialize();
importSetTable.column1 = data[i].column1;
importSetTable.column2 = data[i].column2;
// ... set other columns as needed
importSetTable.insert();
}

})(request, response);

 

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - nowgpt.ai

Dr Atul G- LNG
Tera Patron

Hi @Ketan Pandey 

 

This will help you

 

https://www.servicenow.com/community/developer-articles/import-set-api-goodbye-srapis/ta-p/2318624#:....

 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************