Request forwarded from ProxyEndpoint to TargetEndpoint should retain query parameters. Setting the flow variable target.copy.queryparams does not work.

The API proxy should forward the same set of queryparams to the target end point. Setting target.copy.queryparams to true does not work. Although, setting target.copy.pathsuffix variable to boolean true or false works as mentioned in the apigee docs.

Note - Trying to use target.copy.queryparams as true and target.copy.pathsuffix as false

1 7 1,825
7 REPLIES 7

Not applicable
@Nisha Mallesh

These variable need to be set using assign Message Policy or Javascript policy in target request flow.

Sample below

target.copy.queryparams=true or false
target.copy.pathsuffix=true or false

Yes, using Assign Message Policy. @Umanng Goel

Setting target.copy.pathsuffix=true will disable copying the query parameters to the back-end API request call.

Since, using Assign Message Policy to add the Query Parameters in target-end-point does not work, the only work-around I found is to directly set the flow variables - request.queryparam.<query_param_name> in the target-end-point.

Suggest me, if there are ways of handling this use-case.

@nmallesh 
I set the same property in an AM policy and it worked for me too.
Make sure you set these in the Target Pre flow.

Hi Nisha (@nmallesh),

Add the following code as DisableProxyPath.js using JavaScript Callout Policy in Target Endpoint PreFlow, to not copy pathsuffix and query params to Target Endpoint resource.

// Disables copying Proxy request parameters to Target request
context.setVariable("target.copy.pathsuffix", false);
context.setVariable("target.copy.queryparams", false);

this does work, tried it in Assign Message policy. Thank you.

@Aswin Segu

Please find the code snippet which can be added in the targetEndpoint.xml file. This code worked for me.

<HTTPTargetConnection>
	<LoadBalancer>
		<Server name="{tagetServerName}">
			<IsEnabled>true</IsEnabled>
		</Server>
	</LoadBalancer>
	<Path>/{target.path}</Path>
	<Properties>
		<Property name="retain.queryparams.enabled">true</Property>
	</Properties>
</HTTPTargetConnection>

Note: if you don't have the tager server then you can replace LoadBalance and path with the URL.