Hi,
I am trying to prove that you can use Apigee Edge to return different values based on a condition. In this case the condition is a variable pulled from a response in JSON.
My conditions are not working. As far as I can tell from the Trace the jsonpath expression is working, and my variable is being identified correctly. (In this example there are two options - ‘CA’ or ‘TX’).
My understanding is that if the condition is satisfied then the step will execute. I would like to return a different statement depending on the value of of the variable. Note that the response here is a standin for a proper route, but I will fill the route in later. For now I just want to prove that it works.
Probably I am missing something obvious, so any help is much appreciated.
Here is my flow:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<Description/>
<FaultRules/>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response>
<Step>
<Name>Extract-Variables-1</Name>
</Step>
<Step>
<Name>Assign-Message-CA</Name>
<Condition>(state = "CA")</Condition>
</Step>
<Step>
<Name>Assign-Message-TX</Name>
<Condition>(state = "TX")</Condition>
</Step>
</Response>
</PostFlow>
<Flows/>
<HTTPProxyConnection>
<BasePath>/pid_apigee_pep</BasePath>
<Properties/>
<VirtualHost>default</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>
</ProxyEndpoint>
<br />
And the extract variables code, for reference:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1">
<DisplayName>Extract Variable - State</DisplayName>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<JSONPayload>
<Variable name="state">
<JSONPath>$.response[0].access[0].attributes.state[0]</JSONPath>
</Variable>
</JSONPayload>
<Source clearPayload="false">response</Source>
</ExtractVariables>