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

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

I'll call the action to a flow to have it trigger daily

How can I iterate the action?

@FriendlyDude 

how many records will be fetched from 1 API end point consumption?

How would you know how many to process?

If you make 1st API call and you know 100 IP addresses are there in JSON response, you can iterate that using For Each and simply extract each IP and pass to flow action as input 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