Can you explain to me variable substitution in a Rest call?

FIKRI BENBRAHIM
Kilo Guru

Hello all,

   I can't understand variable substitution in Rest calls although i have looked at the documentation: Variables substitution in Outbound Rest messages. And in the examples, i can't understand what the names of the variables refer to.

   Please guide me thru this one. Thanks in advance. 

Kind regards

FIKRI BENBRAHIM Mohamed Jawad

1 ACCEPTED SOLUTION

siva_
Giga Guru

Hello JFB, 

 

Variable substitutions are used generally as a placeholder to have different values for different requests instead of hardcoding the values in the end points itself;

Variables are allowed in the Endpoint URL, HTTP Header and HTTP Query Parameter Value fields, and the Content field for POST and PUT methods 

once you use the syntax of ${variable_name} and click auto generate variables related link , you can see the variable substitution parameters are populated with keys and by updating the values there you can check the responses of your end point for different values in these variables. 

This is while you are testing 

But in the actual scripts you can use setStringParamter and setStringParameterNoEscape to populate the variable values while sending the request 

There might be scenario where your end point responds differently based on different values selected on a particular  field in the form which you have used as a variable in your end point ,so here the variable parameter is dynamic which cannot be manually given 

In such a case when you are triggering your rest message through any server script using RestMessageV2 then you can 

use like r.setStringParameter(varName,current.particularFieldValue);

 

Mark this answer as correct if that clarifies your query and also for categorizing this thread as answered .

 

Thanks,

Siva

View solution in original post

5 REPLIES 5

mmaraj1
Mega Expert

when you set dynamic values in your content for your rest message,  you can use variable substitution to test your results.

Use, in the related links, to auto generate variables that would  auto-populate the variables that can be substituted. Input , under 
"test value," the values you would like to substitute (basically when the message sets send off to the target system, it will be sending these test values for the respected dynamic variables).  

Under related links, there is a "Test: link that will send your test message and you can see what type of response you would get if you are trying to connect to your specified endpoint with the variables you gave it. 

 

I hope this helps

 

 

siva_
Giga Guru

Hello JFB, 

 

Variable substitutions are used generally as a placeholder to have different values for different requests instead of hardcoding the values in the end points itself;

Variables are allowed in the Endpoint URL, HTTP Header and HTTP Query Parameter Value fields, and the Content field for POST and PUT methods 

once you use the syntax of ${variable_name} and click auto generate variables related link , you can see the variable substitution parameters are populated with keys and by updating the values there you can check the responses of your end point for different values in these variables. 

This is while you are testing 

But in the actual scripts you can use setStringParamter and setStringParameterNoEscape to populate the variable values while sending the request 

There might be scenario where your end point responds differently based on different values selected on a particular  field in the form which you have used as a variable in your end point ,so here the variable parameter is dynamic which cannot be manually given 

In such a case when you are triggering your rest message through any server script using RestMessageV2 then you can 

use like r.setStringParameter(varName,current.particularFieldValue);

 

Mark this answer as correct if that clarifies your query and also for categorizing this thread as answered .

 

Thanks,

Siva

Mark an answer as Correct so that the question can be removed from the unanswered category if it helps

Thanks,

Siva

Hello,

 

   Thank you very much Siva Kalyan for the interesting details you have given.

 

Kind regards

FIKRI BENBRAHIM Mohamed Jawad