How to dynamically change Base URL and Header Value of a REST Step in a custom action I created

FriendlyDude
Tera Contributor

Hi all,

 

I'm trying to automate updating of CIs through REST APIs and so far, I'm only able to do it for one CI.

 

The process of how this is happening is that I got a REST Step to fetch JSON data from API, then I have a Script Step to parse that JSON data to variables and use those variables to create a record to my custom import set table. With a transform map, the attributes from the custom import set table will be mapped to the target table in the CMDB.

 

The REST Step will contain the Base URL: https://10.100.100.100/api/v1/sample

(The base url contains the IP address of the device where we are getting the data)

Header Value: [API Key of the device]

For me to update multiple CI records, I have to change the Base URL and Header Value for each device I'm trying to get data from.

 

How can I do this?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@FriendlyDude 

you can pass the dynamic URL as input to the action and then use it in REST Step

You must be calling this Flow action from either subflow or flow right?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

I have a list of IP addresses that I will need to do an API call to, and each of it will have a unique API

 

@FriendlyDude 

then you can store those list of IP addresses in system property

Then in main flow get that property value and store in Flow Variable which is an array of String

Then use For Each to iterate and pass the unique IP to that flow action for base URL

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Cent
Tera Contributor

Hi What is the type of the "dynamic URL as input to the action and then use it in REST Step should be"?

Adam Celli
ServiceNow Employee
ServiceNow Employee

You can use Connection Attributes in your Connection configuration to pass in dynamic values as data pills from your Flow/Sub-flow.

 

One other consideration, you should do your best to batch these queries into a single "Get Devices" call instead of making an API call for every single device. Each outbound API call consumes an Integration Hub transaction, so any opportunity to group them together will optimize both your performance and transaction consumption rate.