Closed ghost closed 7 years ago
Are you trying to use environment variables in the request body?
Boomerang uses Mustache.js for string interpolation. You can use your environment variables in the request body like this:
...
<ts:Name>{{variable_name}}</tsv:Name>
...
Mustache doesn't support if else condition. But it supports the inverted condition.
{{#repos}}<b>{{name}}</b>{{/repos}} //if repos variable has truthy value, this block will be rendered
{{^repos}}No repos :({{/repos}} // else this block will get rendered
Please refer the Mustache docs for more info.
Hi Ashwin,
Thanks for looking into this!
Let me reiterate it to explain this case in a better way. I have declared environment variable in "SCRIPT" tab based on which, I would like to execute XML statement which is written in the body tab. As an example, code would be something like this:
------------------------Script Tab---------------------
boomerang.setEnvironmentVariable('Var1', "abc");
------------------------Body Tab----------
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" >
You can write it like this.
------------------------Script Tab---------------------
boomerang.setEnvironmentVariable('Var1', "abc");
------------------------Body Tab----------
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" >
<soapenv:Header>
.........
..................
</soapenv:Header>
<soapenv:Body >
{{#Var1}} /* if Var1 is defined and has value */*
<CreateRequest xmlns="xxxxxxxxxxxxxxx">
...........
...........
........
</CreateRequest>
{{/Var1}}
{{^Var1}} * /* else execute below create request*/*
<CreateRequest xmlns="xxxxxxxxI">
...........
...........
........
</CreateRequest>
{{/Var1}}
</soapenv:Body>
</soapenv:Envelope>
Please note that currently there is no way to validate the value of variable like this Var1=='abc'.
and to retrieve the response of other request, please refer the Script docs.
Hi
I am a first time user of this client and is trying test 'IF/ELSE' statement in a SOAP request but it's not working for me. It is not throwing any error so I think nothing wrong with the Syntax. However, I think issue is how I am checking conditions in IF statement as it always skips the code underneath in it. Have tried many syntax from google but none of them worked. I am sure I am missing something silly. Can anyone please share a sample code if you have done this before. Below is what I am trying: