Search code examples
parametersapigee

How to remove case insensitive query parameters with Apigee?


Using Apigee API proxy, my target endpoint is case-insensitive regarding accepting parameters. I'd like to strip out some parameters from the request, but how do I do that in a case-insensitive manner?

The Apigee documentation mentions:

<AssignMessage name="AssignMessage-1">
  <AssignTo createNew="false">request</AssignTo>
  <Remove>
    <QueryParams>
      <QueryParam name='apikey'/>
    </QueryParams>
  </Remove>
</AssignMessage>

Using this example, I also want to strip out apiKey, APIKEY, or any other case combination.

I tried doing it with JavaScript, but the parameters were NOT removed:

var apikey = 'apiKey'; // Found by looping through the parameters.
delete context.targetRequest.queryParams[apikey];

Solution

  • JavaScript is the right answer. You can remove a query parameter using the following JavaScript code:

    var apikey = 'apiKey'; // found by looping through the parameters
    context.removeVariable("request.queryparam." + apikey);
    

    See the Apigee variables reference for more information.