How do I transform the path between the proxy and the target load balancer endpoint?

My APIGEE API proxy base path is /ident/post/webhooks, and when the full url https://apigee.url.com//ident/post/webhooks/foo then I need to reroute the traffic to the load balancer url https://ilb.url.com/api/mynew/test/foo. So the path suffix /foo I need to add allong with the load balancer path /api/mynew/test.

I tried with a AssignMessage policy but didn’t worked

<AssignMessage async="false" continueOnError="false" enabled="true" name="RewriteWebhookTargetPath"> <DisplayName>Rewrite Webhook Target Path</DisplayName> <Properties/> <Set> <Path>/api/mynew/test{request.pathsuffix}</Path> </Set> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage> 

I could see the target url is wrongly forwarded to https://ilb.url.com/foo

Also the load balancer is defined in target connection tag.

Target URL is not enough. In my case, I need point to target connection

<HTTPTargetConnection>   <LoadBalancer>     <Server name="httpbin-test-ue1"/>     </Server>   </LoadBalancer>   <Path>/</Path> </HTTPTargetConnection> 

Example code

Hello,

Is there any specific reason why you aren’t dynamically setting the path variable as a part of your HTTPTargetConnection element declaration? Something as follows should work to expectation given your use case:

Assign Message Policy (set in the Proxy request):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> AM-Rewrite-Path mycustompath /api/mynew/test true

Target endpoint HTTPConnection:

{mycustompath}

The path suffix should already be set OOTB (enabled by default), so there shouldn’t be a need to set it via flow variable

Please let me know your thoughts, thanks!

1 Like