Hi Team, I am trying to use some conditions in the...
# general
m
Hi Team, I am trying to use some conditions in the response body but I couldn’t achieve and also I couldn’t find any documentation in the website as well. Basically according to the request header body field value should be sent.
Hi @Tom, I do see you have already replied same kind of question but sorry I couldn’t still build the above case.
l
Let me take a look and see if I can see what is wrong
You might be able to do this without the
assign
but I already had an example where I was using this so I left it in. This response file should do what you are looking for:
Copy code
{{#assign 'correctionID'}}{{request.headers.correctionID}}{{/assign}}
{
  "field1": "{{#eq correctionID '1'}}{{now offset='1 years' format='yyyy/MM/dd'}}{{else}}{{now offset='3 years' format='yyyy/MM/dd'}}{{/eq}}"
}
When I send a request with a
correctionID
header of
1
I get the following response:
Copy code
{
  "field1": "2025/04/17"
}
Any other value in that same header returns:
Copy code
{
  "field1": "2027/04/17"
}
m
sorry for the late reply, thanks for the reply. Can you pls help me to add two condition on the above example ?
l
Hi, can you post what you have tried that isn't working?