Forum Discussion
- OlivierS10 years agoLithium Alumni (Retired)
vaishnavi have you try to display the value of the 'a_token' variable to see its content?
<#assign a_token = json_response.access_token />
Or try:
<#assign a_token = json_response.access_token?json_string />
- vaishnavi10 years agoExpert
When I print ${a_token} it print the correct string value but its not working in API header.
I have tried j_string, js_string, json_string but nothing is working.
I getting below error :
error making http request: Unauthorized
Is here any issue due to encoding of API response ?
when I print ${a_token?url} for <#assign a_token = "ASfJllLBFpNPucOl7hMQptwyMQ==" />
output is : ASfJllLBFpNPucOl7hMQptwyMQ%3D%3D
and when I print ${a_token?url} for <#assign a_token = json_response.access_token />
output is : ASfJllLBFpNPucOl7hMQptwyMQ%26%2361%3B%26%2361%3B
means it takes HTML encoded access_token as ASfJllLBFpNPucOl7hMQptwyMQ==
Note here : = is HTML encoded equivalent of equal sign( = )
and again encodes it to MQ%26%2361%3B%26%2361%3B
Does anyone know how to decode HTML encoded string in freemarker variable?
- PaoloT10 years agoLithium Alumni (Retired)
Hi vaishnavi
I have encountered the behavior once and it is being investigated ( JakeS may be interested in this topic). In the meantime, to overcome these encoding issues in the past, I have used a workaround
<#assign token = jsonResp.access_token?replace("&", "&")?replace("=", "=")?replace("<","<")?replace(">",">")?replace("&quot;","\"") />
This is, of course, just a workaround using string replace but it did the trick for me.
Thanks
Related Content
- 11 months ago