Fetching value of an Query param having special characters ex: '+' using ExtractVariables Policy

I have a queryparam called key and its value "148BWGD+aUZWag/Y==".

When i tried to fetch value of variable "key" using ExtractVariables policy,

I am getting "148BWGD aUZWag/Y==" in trace.

i.e., + is being replaced with a space.

How can i retrieve original value of varaible key withiout replacing + by space?

Solved Solved
0 2 766
1 ACCEPTED SOLUTION

That may be correct behavior depending on how your client is sending in the query param.

The + is a reserved character in URLs; RFC3986 states that it must be percent-encoded by the client before sending the request. Otherwise + is treated as an encoding for the space character, in other words decimal 32 in ASCII.

Therefore: if your client is really sending in a query parameter containing "148BWGD+aUZWag/Y==", then the specification says that the server (Apigee in this case) should interpret that as "148BWGD aUZWag/Y==". Which is what you are seeing.

To allow Apigee to get a + character, the client must send the properly encoded form: "148BWGD%2BaUZWag/Y==".

See here for information on Percent-encoding. And see here for information on encoding within query parameters, specifically the + character.

View solution in original post

2 REPLIES 2

That may be correct behavior depending on how your client is sending in the query param.

The + is a reserved character in URLs; RFC3986 states that it must be percent-encoded by the client before sending the request. Otherwise + is treated as an encoding for the space character, in other words decimal 32 in ASCII.

Therefore: if your client is really sending in a query parameter containing "148BWGD+aUZWag/Y==", then the specification says that the server (Apigee in this case) should interpret that as "148BWGD aUZWag/Y==". Which is what you are seeing.

To allow Apigee to get a + character, the client must send the properly encoded form: "148BWGD%2BaUZWag/Y==".

See here for information on Percent-encoding. And see here for information on encoding within query parameters, specifically the + character.

Thank You for providing more information.