Proxy is appending path to target end point

Following is my use case. I have a proxy with base path {myBasePath} . I am hitting this proxy with the path https://myapigeedomain.com/myBasePath/path1/path2/path3/somepathvariable/path4. My target endpoint host is https://mytargetendpoint.com . I want to call my target with following path ...

https://mytargetendpoint.com/path3/somepathvariable/path4 . I want to remove /path1/path2 from my request path and just get /path3/somepathvariable/path4 which I need to append at the end of target end point. How to do that ? Right now it's getting wrong endpoint which is https://mytargetendpoint.com/path1/path2/path3/somepathvariable/path4 which has something unwanted.

Solved Solved
0 8 754
1 ACCEPTED SOLUTION

Can you just modify your basepath so that it is myBasePath/path1/path2 ?

View solution in original post

8 REPLIES 8

Can you just modify your basepath so that it is myBasePath/path1/path2 ?

I tried doing it and it works. But is there a way to change this ? Because right now I just have one end point, but I have more end point which I would be adding. Those might not even have path1/path2 . It could be different. Only basepath is common.

If you're adding a second endpoint, the thing to add is .... another Proxy Endpoint. The Proxy Endpoint is a formal entity within Apigee Edge. You can have multiple proxy endpoints in a single proxy bundle. Each has an independent proxy basepath.

proxy endpoint basepath
proxyendpoint1 myOriginalBasePath/path1/path2
proxyendpoint2 myOriginalBasePath/path3
proxyendpoint3 myOriginalBasePath/something/else
proxyendpoint4 this_need_not_be_common/path4

@Dino-at-Google - Just curious, is it a good practice or recommended approach to have multiple proxy endpoints with different basepaths in an api proxy?

Yes. It's a feature of the platform. It's documented, tested, and supported. It's a good idea if you want to group proxy capability and organize logic by basepath.

@Dino-at-Google Thank you for confirming this, I was under the impression that this is not a good idea since swagger 2.0 didn't support multiple basepaths.

@jivan patil

You can use Extract Variables to have

<URIPath>  <Pattern ignoreCase="true">/path1/path2/{desiredTargetPath}</Pattern></URIPath>

and in your target URL you can have https://mytargetendpoint.com/{desiredTargetPath}

Ensure that you have target.copy.pathsuffix set to false, else by default the entire proxy.pathsuffix will be appended

This will work, but I don't recommend this approach. There's a simpler way.