How to make IF conditions in JSON request body

harishdasari
Tera Guru

Hi,

I want to check for condition in JSON while sending the request in Integration. How can I use IF statement condition or something similar for validating the conditions in JSON request.

For example :: 

If(x = 'a')

{

"components": [{
"id": "78901"
}]

}

else

{

"components": [{
"id": "123456"
}]

}

4 REPLIES 4

asifnoor
Kilo Patron

Hi,

You should create json request based on IF condition rather than trying to add If condition within json request.

Raghu Loganatha
Kilo Guru

Harish, 

I believe you are trying to set value of ID in Json before passing the value to other application. You need to write your If condition in the business rule or the script include from where you are calling the web service.


~Raghu.

harishdasari
Tera Guru

Thank you for the response, could you please help me how can I do that with your sample code of explanation.

I have written the business rule, it is not an issue.

Now what I need is, I have 2 conditions. 

it should do something like this below

 

If(true)

{

payload 1

}

else

{

payload 2

}

 

can you share your business rule code?