From 1ee3e60b9a019df3f126470a8850fa5a8c6b97c8 Mon Sep 17 00:00:00 2001 From: ChandBasha-code Date: Sun, 12 Oct 2025 16:21:55 +0530 Subject: [PATCH 1/2] =?UTF-8?q?Create=20Device=20Data=20Loader=20=E2=80=93?= =?UTF-8?q?=20REST=20API=20of=20Intune=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ata Loader \342\200\223 REST API of Intune README.md" | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 "Integration/RESTMessageV2/Reusable RESTMessageV2 retry pattern/Device Data Loader \342\200\223 REST API of Intune README.md" diff --git "a/Integration/RESTMessageV2/Reusable RESTMessageV2 retry pattern/Device Data Loader \342\200\223 REST API of Intune README.md" "b/Integration/RESTMessageV2/Reusable RESTMessageV2 retry pattern/Device Data Loader \342\200\223 REST API of Intune README.md" new file mode 100644 index 0000000000..bd252a746e --- /dev/null +++ "b/Integration/RESTMessageV2/Reusable RESTMessageV2 retry pattern/Device Data Loader \342\200\223 REST API of Intune README.md" @@ -0,0 +1,9 @@ +The getDevices() function automates the process of: + +Calling a REST Message defined in ServiceNow. + +Retrieving device data in JSON format. + +Handling pagination using the @odata.nextLink attribute. + +Inserting each record into a specified Import Set table for further transformation. From ecf7de8c44aceff77d15675edd8aef0d579f14e0 Mon Sep 17 00:00:00 2001 From: ChandBasha-code Date: Sun, 12 Oct 2025 16:23:34 +0530 Subject: [PATCH 2/2] Create Device Data Loader - REST API Intune.js Intune device data into source to importset table with API --- .../Device Data Loader - REST API Intune.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Integration/RESTMessageV2/Reusable RESTMessageV2 retry pattern/Device Data Loader - REST API Intune.js diff --git a/Integration/RESTMessageV2/Reusable RESTMessageV2 retry pattern/Device Data Loader - REST API Intune.js b/Integration/RESTMessageV2/Reusable RESTMessageV2 retry pattern/Device Data Loader - REST API Intune.js new file mode 100644 index 0000000000..1b19059ffe --- /dev/null +++ b/Integration/RESTMessageV2/Reusable RESTMessageV2 retry pattern/Device Data Loader - REST API Intune.js @@ -0,0 +1,37 @@ +getDevices: function(importSetTable) { + var endPoint = null; + var isEndofDevices = false; + + while (!isEndofDevices) { + // Call REST Message Method + var url = new sn_ws.RESTMessageV2('Servicenow-Rest', 'GetDevice'); + + if (endPoint !== null) { + url.setEndpoint(endPoint); // Set the endpoint from REST Message method + } + + var response = url.execute(); // Execute endpoint + var responseBody = response.getBody(); // Capture the response body + var httpStatus = response.getStatusCode(); // Capture response status code (200 for success) + + // Parse the response to JSON format + var parsedResponse = JSON.parse(responseBody); + var deviceData = parsedResponse.value; + + // Loop through each record and insert data into import set table + for (var i = 0; i < deviceData.length; i++) { + importSetTable.insert(deviceData[i]); + } + + if (parsedResponse["@odata.nextLink"]) { // Pagination : Check if response has next link + // Copy next data link to endPoint variable + endPoint = parsedResponse["@odata.nextLink"]; + } else { + isEndofDevices = true; + } + } // End of while loop + }, +Calling from datasource + + var data = new Utils().getDevices(import_set_table); +