Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

apigee

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.

like image 742
Deepti N M Avatar asked Mar 19 '23 19:03

Deepti N M


1 Answers

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.

like image 172
akoo1010 Avatar answered Apr 28 '23 03:04

akoo1010