rest api variable substitution

soibam_ana_sing
Giga Contributor

We are facing some challenges in complex variable substitution in outbound rest API web service.   

Endpoint:  https://<ip_address>/rest/server-hardware?filter=${filter}

Method: GET

Variable substitution:  "name EQ 'SGH817YECA, bay 12' "

 

find_real_file.png

yours helps/inputs are greatly appreciated. 

 

Regards

Soibam 

 

 

15 REPLIES 15

may i know your instance version details also have you checked the mid server status? is that validate ? 

The mid server is validated and up. its developer instance with Jakarta version                    

are you doing it on PDI then i can give a try 

Yes , its personal developer instance. 

A-N
Tera Expert

Hi  soibam.ana.singh,

It appears that your Endpoint contains spaces, quotes, comma which might be a cause for concern

My suggestion is that instead of passing that as a single variable you break-up your Endpoint(handle all the single-quotes,comma delimiters in the endpoint definition as shown below) and use multiple variables 

Your Endpoint should look like this

 

find_real_file.png

Note the space between ${1} and ${2} also the single-quote before ${3} and then a comma followed by ${4} ending with single-quote

Here's what your variable substitutions should look like

find_real_file.png

Since you are handing all the single-quotes, spaces etc before passing the variable the "No escaping" option should work fine

The REST Message script should look something like this

 var r = new sn_ws.RESTMessageV2('<name>', 'Default GET');
 r.setStringParameterNoEscape('3', 'SGH817YECA');
 r.setStringParameterNoEscape('4', 'bay 12');
 r.setStringParameterNoEscape('1', 'name');
 r.setStringParameterNoEscape('2', 'EQ');

Try this out, hopefully it should resolve the error