How to Append dynamic request path to target end point based on request method.

Not applicable

Hi,

I would like to send the dynamic path in the request uri to target.

1.something like this

/abc(dynamicvalue)?apikey=<apikey>

How can I do this ??

Dynamic value is fetched in extract variable.

0 4 2,637
4 REPLIES 4

What you describe happens automatically. For example, suppose the basepath for your API proxy is /svc1 . Suppose there is a single target endpoint with URL https://internal-server.com/foo . Then, for these given inbound requests, the pass-through API Proxy will send these outbound requests:

inboundoutbound
https://org-env.apigee.net/svc1https://internal-server.com/foo
https://org-env.apigee.net/svc1/abchttps://internal-server.com/foo/abc
https://org-env.apigee.net/svc1/abc?q=defhttps://internal-server.com/foo/abc?q=def

You don't need to configure anything, beyond a reverse proxy, to make that happen.

Hi Dino,

Thanks for the response.

I got the answer for my question.

I have done adding the dynamic path adding to the target in Javascript and it works.

Can you tell me how u achieved it? I am doing the below scenario

1) i have below setup in PROXY endpoint flow (note:- * , it will be customer id)

<HTTPProxyConnection>

<BasePath>/application/tworder/v1/ip-customers/*/ip-users/</BasePath> <Properties/> <VirtualHost>secure</VirtualHost>

</HTTPProxyConnection>

2) i have below setup in TARGET endpoint flow (need to get the above cusomer id and pass in the target end point)

<HTTPTargetConnection>

<LoadBalancer>

<Server name="appTargetURL"/> </LoadBalancer>

<Path>/application/tworder/v1/ip-customers/{need to replace id value from the proxy URI value}/ip-users/</Path></HTTPTargetConnection>

ineed to cosntruct like:

https://hostName/application/tworder/v1/ip-customers/1234567890/ip-users/

How do i replace the value 1234567890 dynamically? i tried with java-script policy

var a=context.getVariable("apigee.customerId");

var b="/application/ipss/v1/ip-customers/"+a+"/ip-users/";

context.setVariable("target.url", b);

Extract Policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-path-variable-from-request">

<DisplayName>Extract-Path-Variable-From-Request</DisplayName> <Properties/>

<URIPath name="customerId">

<Pattern ignoreCase="true">/{customerId}</Pattern> </URIPath>

<Source clearPayload="false">request</Source>

<VariablePrefix>apigee</VariablePrefix>

</ExtractVariables>

Output:- customer is still null

http://ip-userms.sdpamp.com/application/tworder/v1/ip-customers/null/ip-users/

hi - Can you post your question as a new question, please?

6858-ask-a-question.png

I don't answer new questions that are posted as comments on answers to old questions.