Handling Header values having '%' character in 'Assign Message' policy

Not applicable

I am exposing a proxy URL in apigee w.r.t. a backend service. I am copying the (Custom) Header value in the proxy side request to queryparams in backend service URL, using Assign Message policy, as given below:

<Set>

<QueryParams> <QueryParam name="Timestamp">{request.header.Timestamp}</QueryParams> <Verb>GET</Verb>

</Set>

I see that the header values having '%' in it are getting manipulated after passing through Assign Message policy. How to prevent Assign Message manipulating it? For example, it's converting '%' in request header to '%25'...

Solved Solved
0 4 1,163
2 ACCEPTED SOLUTIONS

Not applicable

Given this is a get - any params that get assigned to the query string will by necessity be URI encoded.

Your target should be able to do resolve this with something like (javascript example):

var decodedTimestamp=decodeURIComponent(request.queryparam.Timestamp);

If your target can not decode these you should pass them through as a header.

View solution in original post

Not applicable

I solved using JavaScript.

First I accessed the headers in JS like this : var field_1 = context.proxyRequest.headers['HEADERNAME'];

Then I build the target side URL (JS is then attached to the Post Flow - Request):

var url = "http://ww.abc.com/someresource?"

context.setVariable("target.url", url + "QUERYPARAM1=" + field_1)

Hope this helps..

-Aneesh.

View solution in original post

4 REPLIES 4

i think the '%' is just URL encoded, your backend service should be able to decode it without problems.. are you seeing any issues?

Not applicable

Given this is a get - any params that get assigned to the query string will by necessity be URI encoded.

Your target should be able to do resolve this with something like (javascript example):

var decodedTimestamp=decodeURIComponent(request.queryparam.Timestamp);

If your target can not decode these you should pass them through as a header.

Not applicable
@aneesh_ananthakrishnan

Have you found out any workaround to this situation? as i have also been facing this issue since long.

Not applicable

I solved using JavaScript.

First I accessed the headers in JS like this : var field_1 = context.proxyRequest.headers['HEADERNAME'];

Then I build the target side URL (JS is then attached to the Post Flow - Request):

var url = "http://ww.abc.com/someresource?"

context.setVariable("target.url", url + "QUERYPARAM1=" + field_1)

Hope this helps..

-Aneesh.