Running a REST query to populate a table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2014 12:39 PM
In the process of setting up an integration between a 3rd party CMDB and ServiceNow. They have provided a REST API to query their database.
I have used both SOAP and REST queries in the past to pull specific data on demand and use it, but in this case, I'm looking to take the response and put it into a data source so that I can transform it into the CMDB.
Does anyone have any suggestions for the following:
1. Where should the REST messages be called from? I was thinking a scheduled job since it does not need to be on demand.
2. What method should I use to take the response and write that to a table?
3. Where should I store the response form the REST message so that I can run a transform against it and populate various cmdb tables? I was thinking for servers and computers, I could use the imp_computer table and utilize the transform script (with some adjustments) that already exists.
Thanks for your input.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2015 11:28 AM
Thanks SO much Frank, this is sooo very helpful for me!!! I should mention that I think I have figured out the request URL that matthewsglen is using. He is querying the computer_reports and that's where he was able to gather all of the information in one request.
I think what he did was go to Search Inventory > Create a search and save name
The api query is here:
../JSSResource/computerreports/name/{name}
I think I'm going to do it this way so I can use one request like the example provided by matthewsglen.
Again everyone here has been a huge help so Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2016 10:29 AM
Hi Frank,
Have you configured this to set up an incremental import? In other words, we only want to pull records that have been updated in the past hour. That way we are not pulling in all records into our import set table every time we run an import. We would like to import several times per day, every 30 minutes. Thus we will need a solution for pulling data incrementally.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2016 10:08 PM
Hi kda,
we have it done via a full import to the import set table. But i guess you can use the report_date_utc field coming with the probe to only get the systems that got updated between a different time. Haven ´t tried this but it looks like a good way if you got a lot of system.
You have 2 fields for the report date (utc and epoch) .
So if you modify the scheduled job to only insert the record to the Import Set table IF the report_date_utc is not older then (in your case ) 1 hour, then this should be good.
Thanks
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2016 01:25 PM
Hi Matthew Glenn,
Can you paste the responseBody of the Rest message that you were executing. I was not able to get the length of the Json that is generated from REST call.
Response :
{"Response":{"Tags":{"Resource":{"Type":"network-interface","ID":"eni-23553525"},"Resource":{"Type":"instance","ID":"i-b5953222"},"Resource":{"Type":"security-group","ID":"sg-d7d54354"}}}}
TIA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2016 03:43 PM
I no longer have access to the instance/api that this was built for, so unfortunately cannot provide the responseBody for you.
Looking at the response you provided though, you might be able to do something like this:
var jsonString = response.getBody();
var parser = new JSONParser();
var parsed = parser.parse(jsonString);
for (i = 0; parsed.tags.resource.length; i++){
//do whatever you want in here, you can use the data like this
var type = parsed.tags.resource[i].type;
var id = parsed.tags.resource[i].id;
}
While I can't say 100% that this will work, it should give you an idea.