The use case here is that the target endpoint URL has to be changed based on some conditions. The JavaScript policy used to overwrite "target.url" does not get the call routed to the new target. It still routes to the 'Default Target Endpoint URL' set on the 'Overview' tab of the API Proxy. Here is the JavaScript:
context.setVariable("target.url", url);
where URL is the new target URL value that needs to be set.
http://apigee.com/docs/api-services/content/javascript-object-model shows a similar example and http://apigee.com/docs/api-services/api/variables-reference confirms that the variable reference is correct.
Please ensure the policy for the JavaScript is in the Targets side of the flow (vs. Proxies side). You won't see the change take in effect if the policy is executing in the Proxies side of the flow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With