In an Apigee API Proxy, why does rewriting "target.url" via a JavaScript policy not route to the new target?

StackOverflow https://stackoverflow.com/questions/23277279

  •  09-07-2023
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top