Hi all,
I'm new to Apigee. I'm working on a scenario, where I need to mention a condition if the response.content
{
Res:[{filed 1},{field 2}...{filed n}]
}
has less than 10 fields , I need to make a call to other service.
what is the condition to be used?
I tried below two options, none of them worked
1.<Condition>(response.content.length < 10)</Condition>
2. <Condition>(response.header.Content-Length < 10)</Condition>
build error:
The content of elements must consist of well-formed character data or markup.]"
Can some one suggest?
Thanks in advance
You could add a Javascript callout in which you set a boolean flow variable to true if the number of fields in Res is greater than 10.
It'd be something like this:
enoughFields = Object.keys(context.proxyRequest.body.asJSON.Res).length > 10; context.SetVariable("hasEnoughFields", enoughFields);
Then you could check your condition as
<Condition>hasEnoughFields = "false"</Condition>
I haven't actually tested this code (so there may be some syntax error), but I hope you get the general gist
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |