This proxy is extracting 2 variables in a proxy request flow. After the variables have been confirmed as extracted (via trace logs), I am using an Assign Message to format a request to be sent to the back end target server.
What I am doing:
If the client provides the parameter in the request, then I will extract the variable, and assign it as "variable.A".
If the client does not provide the parameter in the request, then I will assign it a defaulted variable obtained from an Access Entity policy triggered in the proxy preflow and call it "variable.B".
The AssignMessage/AssignVariable should determine:
- If "variable.A" does not exist or is null, then use "variable.B"
Below is the AssignMessage:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="AM-productPricingPayloadDefault"> <AssignVariable> <Name>productId</Name> <Ref>variable.A</Ref> <Template>{variable.B}</Template> <AssignVariable>
What I am seeing:
If "variable.A" is provided by the client, then the proxy executes as expected. However, if "variable.A" is not provided, then the proxy does not substitute using "variable.B".
What I expect to see:
If the client does not send parameter to populate "variable.A", then the AssignVariable would look to the "Template" section and use "variable.B".
Again, I have confirmed that "variable.B" is a legitimate/populated cached variable via Apigee Trace Logs and according to the Apigee Docs (https://docs.apigee.com/api-platform/reference/policies/assign-message-policy#assignvariable). What I am attempting should work using the Template functionality so I am assuming I simply have a format/syntax issue that I am not seeing. I would also prefer to NOT use a JavaScript for this. Any assistance would be appreciated.