Change a queryparam that can be passed in with any case to any case

Users can send in "request.queryparam.Token" or "token" or "TOKEN" can i use assign message policy to stanardize it to "token"????

for example request can be

"......./ApigeeAPI/V1/?Token=12345" OR

"......./ApigeeAPI/V1/?token=12345" OR

"......./ApigeeAPI/V1/?TOKEN=12345" OR

I need to be able to standardize the queryparam to token

so that i can move it to the header.

Please help, preferably not with JS

if the only way is with js please include everything i would need to do this.

1 1 978
1 REPLY 1

@yehuda.g,

You can do this with JavaScript as follows:

// Query Param to be removed
var token = "token";
var tokenValue ;

var queryParamsList = request.queryParams;
for(var queryParam in queryParamsList){
    // convert to lower case and check if the query parameter is token
    if (queryParam.toLowerCase() == token) {
        // Get the value of the query parameter
        tokenValue = context.getVariable("request.queryparam." + queryParam);
        // Remove the query parameter
        context.removeVariable("request.queryparam." + queryParam);
    }
}
// Set the Header
context.setVariable("request.header.token", tokenValue);