How to set Query Parameters in an REST Message from a third party web service

lhai
Kilo Contributor

For example, I have this web service: http://server/Test-service/Test('AAA')

In the Rest Message configuration, I need to set it up in such a way that when I call the web service, I can pass a value like 'AAA'.

I tried setting the endpoint as http://server/Test-service/Test('AAA') then tested it and it works correctly.

But I need to pass the value to web service not to hardcode it in the endpoint.

Thanks in advance.

5 REPLIES 5

Ashok Katam
Mega Guru

Hi Alyssa



You need not to set Query parameters in end point



If you open your HTTP Method what ever that you are using.. You can see the option 'HTTP Query Parameters'. You can add your query parameters over there


lhai
Kilo Contributor

Hi Kumar,



Thanks for your input. I have tried doing this but unfortunately it did not work for me. I tried using pankaj_puniani instead and it worked fine. Nevertheless, your input is very much appreciated!





Regards,


Alyssa


pankaj_puniani
ServiceNow Employee
ServiceNow Employee

Hi Alyssa,



try setting endpoint something like this :   http://server/Test-service/Test('${input}')



and while invoking this rest message in script, use RestMessagv2 setStringParameter API, something like:



var restMessage = new sn_ws.RESTMessageV2('<Rest message name>', '<Rest message function name>');


restMessage.setStringParameter('input','AAA');




Hope it helps,



Pankaj


Hi Pankaj,



        This method worked for me. Thank you so much!!






Regards,


Alyssa