Remove All Query params from request

Hi team,

How can i remove all query parameters from request before sending it to target endpoint.

I applied Assign message policy.

AM-RemoveQueryParams target.copy.pathsuffix false true

Applied policy on target proxy and request flow.

But it doesn’t work.

thanks.

Try using below JS Policy in TargetEndpoint Preflow,

 // Print the request before removing the query parameter
context.setVariable("MyRequest1", request);

// Get all the query parameter names
var queryParamNames = context.getVariable('request.queryparams.names');

//convert it to string array.

queryParamNames = queryParamNames.toArray();

for (var i = 0; i < queryParamNames.length; i++) {
   print("queryParamName = " + queryParamNames[i]);
   // Remove the query parameter from the request
   context.removeVariable("request.queryparam." + queryParamNames[i]);
}

// Print the request after removing the query parameters
context.setVariable("MyRequest2", request);

This was written by Amar @Devagowda in some early posts.

HI @abnamro Test

Try adding the following code to your Assign Message policy

<Remove><QueryParams/></Remove>

Its documented as well. Check the “/ element” in this page

1 Like