AnsweredAssumed Answered

Custom response with parameters

Question asked by lrosique on Nov 25, 2016
Latest reply on Dec 9, 2016 by lrosique

   Hi there,

 

 I had some question regarding the body response for a REST call. It is written we can you {{ }} to replace parameters. For instance,

{{= request_URLPARAMETER0}} will be replace in the response if written like that in the body response.

My question is : how can we use conditions in {{ }} ? I couldnt figure out the syntax (on wiki they say : }} can execute arbitrary Java code and even generate realistic "everyday" data such as a valid credit card number {{=[:Credit Card:]. (Magic Strings - DevTest Solutions - 8.0.1 - CA Technologies Documentation).

 

I'd like to do something like that

<foo>{{if (request_URLPARAM == 1) { print("case1") } else { print("case2") }</foo>

but my goal is more something like

if (param == 1) {

   <foo1>bar1</foo1>

} else {

   <foo2><foo3>bar2</foo3></foo2>

}

because I have 70 possible values for my param, and in the body response i have 50 objects which are attached to one value, so I can easily say "this(these) one(s) should be sent for value XX", etc...

 

Thanks in advance, I don't know if I'm clear,

Lambert.

Outcomes