Variables in a REST Message

jakeelliot
Kilo Contributor

I'm creating a REST message and triggering it to execute through a workflow. This is my first attempt at a REST message. I need to pass the RITM number back to the third party when a request is approved. The endpoint my the third party is as follows -- https://hosted-site/test/rest/integration/workorder/${u_work_order_number}. The third party is initially sending a POST to create a service request. They are sending us the variable called u_work_order_number. Will the rest message endpoint dynamically pick up that number and throw it in the endpoint? Or do I need to set that variable, along with my ${number} variable sent in the payload, somewhere in the REST message before I use it?

REST MESSAGE

find_real_file.png

Call in WorkFlow

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Jake,



Yes that's correct. Anything which is dynamic you will require to create variable substitutions and use those in script.


once you create variable substitution you can click preview script usage and it will show you syntax.



Variable substitution in outbound REST messages


Outbound REST Web Service - ServiceNow Wiki



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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Jake,



Yes that's correct. Anything which is dynamic you will require to create variable substitutions and use those in script.


once you create variable substitution you can click preview script usage and it will show you syntax.



Variable substitution in outbound REST messages


Outbound REST Web Service - ServiceNow Wiki



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

ark6
Mega Guru

You can put this at the line 10 before r.execute



r.setStringParameterNoEscape('number',current.number);


Ankur Bawiskar
Tera Patron
Tera Patron

Hi Jake,



Any update on this?


Can you mark answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.



Regards


Ankur


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

I will know more in about a hour or 2 when we test the functionality....I'm fairly confident it will work based on the input you provided me. Marking correct.