Variable substitution in Rest Endpoint through script include & get variable value from client scrip

Shree14
Tera Contributor

Hi All,

 

I need to put a variable value in Rest Endpoint: https:lookup/${address_id}

 

If I hard code this address in script I'm getting 200 response, but if I add it dynamically through not getting any response/error but I could able to log the variable value correctly in System Logs.

 

var r3 = new sn_ws.RESTMessageV2('smaty_test', 'Int complete address'); //Rest MSG & Method
        r3.setStringParameterNoEscape('address_id', add3); //add3 - 'PD4DPC8DPgNHT09HTExGS00DOjE4'
 
Please suugest if anything to be added additionaly/ make change in above code
 
Thanks,
Padma
6 REPLIES 6

Jitendra Diwak1
Kilo Sage

Hi @Shree14,

 

Variable value format: Ensure that the format of the add3 variable matches what the endpoint expects. If it's expecting a specific format or encoding, make sure add3 complies with that

 

Please accept my solution if it resolves your issue and thumps 👍 up 

 

Thanks 

Jitendra 

Please accept my solution if it works for and thumps up.

Thanks @Jitendra Diwak1 .

 

but there is no format required, without any format if I give value :  'PD4DPC8DPgNHT09HTExGS00DOjE4'.. the response is 200.

 

But I want to add this value through varaiable.

 

Thanks,

Shree

SN_Learn
Kilo Patron
Kilo Patron

Hi @Shree14 ,

 

Please try the below:

var r3 = new sn_ws.RESTMessageV2('smaty_test', 'Int complete address'); //Rest MSG & Method
 r3.setStringParameterNoEscape('address_id', add3.toString()); //add3 - 'PD4DPC8DPgNHT09HTExGS00DOjE4'

 

Please Mark My Response as Correct/Helpful based on Impact

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Shree14
Tera Contributor

add3 is already stored as String.

 

var id = 'PD4DPC8DPgNHT09HTExGS00DOjE4'9;

add3 = id.toString();