I have created multiple target-end points based on my back-end servers. Each target end point has a fixed URL.
URL is configured as -
<HTTPTargetConnection> <URL>https://example.com/test/</URL> </HTTPTargetConnection>
I have noticed that "proxy.pathsuffix" is automatically getting added to url (
https://example.com/test/). How can I avoid this?
Regards,
Kamesh
Solved! Go to Solution.
In order to do this you need to use JavaScript and set a variable. The code would be:
context.setVariable("target.copy.pathsuffix", false);
Similar to the javascript above, we are doing this via an AssignMessage policy in the target endpoint request flows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage name="AssignMessage.DisablePathCopy"> <AssignVariable> <Name>target.copy.pathsuffix</Name> <Value>false</Value> </AssignVariable> </AssignMessage>
In order to do this you need to use JavaScript and set a variable. The code would be:
context.setVariable("target.copy.pathsuffix", false);
I am trying to avoid JavasScript callout just to set variable. Is there any other way, not sure why assign message policy does not work.
I am trying to avoid JavaScript callout to just set variable. Not sure why assign-message policy does not work. Is there any other approach.
You can also put the property target.copy.pathsuffix in the target endpoint properties
<HTTPTargetConnection> <URL>https://www.google.com</URL> <Properties> <Property name="target.copy.pathsuffix">false</Property> </Properties> </HTTPTargetConnection>
@Divya Achan I don think this works. I just tested the above way you are suggesting and its not working. May be its something we can expect in the future.
Not Working for me
Hi @Kameshwar Singh as @Michael Malloy mentions you can use a JavaScript policy with the statement context.setVariable("target.copy.pathsuffix", false); but make sure to attach that policy in the PreFlow segment of the "target endpoint" not the "proxy" (see attached image) for it to work. @Divya Achan
Works Fine, Need to add Pre Flow - Target Endpoint as Suggested
I realize this is an old topic, but it's something I am having issues with.
I would like to modify the path appended to the target connnection.
As a starting point, I tried the above suggestion to set `target.copy.pathsuffix` to `false`, but doesn't seem to do anything.
Is there a variable somewhere I can modify?
I'm also looking at the the thread here.
Assuming:
1. HTTPTargetConnection exists
2. I have a JavaScript policy at the "Target Endpoints" preflow
Given the above, should the following code in the JS policy work?
context.setVariable('target.copy.pathsuffix', false); context.setVariable('target.url', 'https://httpbin.org/get');
It doesn't seem to matter what I do, the proxy request path is always appended to the target connection URL.
Dear @williamking,
All you have to do is to create a Javascript Policy in the TargetEndpoint Pre-Flow and set the the value of the target.url with any new value. I have tried this in my org and it worked fine.
context.setVariable("target.url", 'https://httpbin.org/get');
To ensure that target.url is not set always, I modified the code to set the target.url with my desired url only if the path suffix and request.verb matches specific values respectively as shown below.
var pathsuffix = context.getVariable('proxy.pathsuffix'); var requestverb = context.getVariable('request.verb'); if(pathsuffix=="/variable" && requestverb=="GET") { var url = "https://httpbin.org/get"; context.setVariable("target.url", url); }
This is to ensure that
I have also attached my sample API Proxy (TestRemovalofPathSuffix) for reference.
Regards,
Amar
Similar to the javascript above, we are doing this via an AssignMessage policy in the target endpoint request flows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage name="AssignMessage.DisablePathCopy"> <AssignVariable> <Name>target.copy.pathsuffix</Name> <Value>false</Value> </AssignVariable> </AssignMessage>
Uses a builtin policy. Preferred over a Javascript policy.
I tried the up voted answer from Divya Achan, but that didn't seem to work. I used a message policy and assigned a variable as shown here and this worked.
Thanks, this helps. A small correction. The policy should be attached to the target endpoint request preflow
This worked well for me.
Tried to update through javascript and set the Property in the TargetEndpoint too, did not work though.