How to bring data into ServiceNow through REST Step with Flow

Chris Roser
Giga Contributor

I'm currently working on bringing VM information into the CMDB. Currently I have a REST Step Action setup within Flow Designer that is currently bringing info in. However, the data is paginated. Because I don't have Data Streams (IntegrationHub Enterprise) I have to have a separate Flow that runs a script to cycle through the pages and pull the VM information 200 items at a time. 
Where I'm stuck is I need to know how in the world to get this information into the CMDB from here. Initially I was looking into IntegrationHub ETL, but that fundtions off of a Flow Action, not an entire Flow. Basically need to know how to get past the pagination hurdle and get the information imported into CMDB.
Whether through what I've done so far, or some other way I'm not aware of, I'm open to any and all information I just haven't been able to find much to get this setup. Thank you!

1 ACCEPTED SOLUTION

If you can download the Service Graph Connector for SolarWinds in a development instance it would be a good example of how to do this.

It goes from a scheduled data import -> data source -> IntegrationHub Rest Action -> import set table -> RTE -> IRE -> CMDB

You would configure when you want it to run via a scheduled import.  I have attached some screenshots to help you, but as mentioned actually seeing it in an instance would be more beneficial.

find_real_file.png

find_real_file.png

I had to remove a lot of script to get this in one screenshot, but it captures the intent:

find_real_file.png

find_real_file.png

 

In SolarWinds case, it's fairly basic so we don't actually need a scripted data source.  The API is a JSON POST that takes a sql like query.  The pagination has to be part of that query so we modify the query in script before sending the REST request.

View solution in original post

9 REPLIES 9

If you can download the Service Graph Connector for SolarWinds in a development instance it would be a good example of how to do this.

It goes from a scheduled data import -> data source -> IntegrationHub Rest Action -> import set table -> RTE -> IRE -> CMDB

You would configure when you want it to run via a scheduled import.  I have attached some screenshots to help you, but as mentioned actually seeing it in an instance would be more beneficial.

find_real_file.png

find_real_file.png

I had to remove a lot of script to get this in one screenshot, but it captures the intent:

find_real_file.png

find_real_file.png

 

In SolarWinds case, it's fairly basic so we don't actually need a scripted data source.  The API is a JSON POST that takes a sql like query.  The pagination has to be part of that query so we modify the query in script before sending the REST request.

Chris Roser
Giga Contributor

Thank you SO much for taking the time to screenshot all of this and type it up. This has provided a lot of clarification and I believe I have a plan of attack now. My primary issue with this was A) trying to avoid scripting as I'm not efficient or good at it and B) trying to use the new 'low code / no code' system so this solution had the lowest technical debt possible. I feel like at this point I'm just wasting time trying to find alternatives whereas I should have just started with scripting from the get-go. 
My personal complaints aside, thanks again.

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Chris,

It's possible to call REST by creating an Action with a Script step. Loop through the pages and concatenate the result and set it to Output Data. The data can be be passed back to flow where a loop can be used to Create or Update Record.

https://docs.servicenow.com/bundle/sandiego-application-development/page/integrate/outbound-rest/con...

This is what I have currently. It's a REST step in an Action with a Script. The part I'm confused on is how you'd loop through the pages as it would mean doing repeated REST calls and cycling through the pages, which I thought I could only do in a Flow. How would you be able to script it in the Action?

There's a Script step in Action that allows writing arbitrary JavaScript. Just use a while loop in the Script step to loop.

Following is a sample JavaScript using RESTMessageV2() to make a REST call. It's possible to use while loop in the script.

Define Output Variables and can just set the concatenated output from the call to the output variable afterwards.

find_real_file.png