How to pass values dynamically in REST Endpoint

Chandresh
Tera Guru

Hi,

Does anybody have any idea how to pass values dynamically in REST endpoint. In below snapshot, in place of IP, i want a fucntionality that on clicking a button, it should automatically pass the IP address field of the record and parse the response.

find_real_file.png

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Chandresh,



Make the end-point as follows with a variable substitution and this should be for the HTTP method and not the end-point itself


http://adam.kahtava.com/services/whois.xml?query={ipAddress}



Create a variable substitution as follows:


Name - ipAddress


Test Value - ${ipAddress}



While you test use setStringParameter() to set the dynamic value



var ipAddress = ''; // any value you need here


var r = new RestMessage();


r.setStringParameter('ipAddress', ipAddress);



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

Do we need to add ${ipAddress} in both Content and Rest message function parameters or content is enough?

Hi Mallikharjuna,

you need to put ${ipAddress} in the content body where you want the ip address to be present

also you need to create variable substitution or rest message function parameter for that and in name use ${ipAddress}

Could you give link to your question in community since this is an old thread?

Regards

Ankur

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

Nitesh Balusu
Giga Guru

You can also use:

Recordless RESTMessageV2 example

You can just set the endpoint in the script rather than defining in the rest message.