I have an API proxy created with Apigee which works properly. However, I want to make a change in a resource name.
Currently, I have the following resource:
<proxy>/collection/{Id}/product
s which redirects to <myService>/collection/{Id}/products
I want to rename the proxy resource like this:
<proxy>/collection/{Id}/apps
which redirects to <myService>/collection/{Id}/products
What is the best way to to that with Apigee?
Cheers,
Chavdar
If you'd like to proxy requests for /collection/{id}/apps
to /collection/{id}/products
, add a JavaScript policy to the target request with the following snippet of code:
var collection_id = 10; //you should get this using context.getVariable()
var path = '/collection/' + collection_id + '/products'; //new path
var current_target_url = context.getVariable('target.url'); //get the existing target url
context.setVariable('target.copy.pathsuffix', false); //tell apigee to not copy the path over to the target
context.setVariable('debug.js.path', current_target_url + path); //this line is only for seeing the value in the trace tool
context.setVariable('target.url', current_target_url + path); //set the new path