Forum Discussion

pp_01's avatar
pp_01
Mentor
6 years ago

Decoding a value using freemarker in a component or endpoint.

Hey all.

From a response, I am getting a property (sso_id) whose value is coming encoded (cscuser2@gmail.com is coming as cscusers2@gmail.com) which is causing some real problems if I want to validate that if this sso_id exists either through V1 or V2 call because even if I'm trying to use utils.base64.encode(sso_id) or utils.base64.decode(sso_id) for encoding and decoding and then passing the sso_id into V1 or V2 calls it still gets encoded and I'm not able to validate. The case is the same if I try to achieve it in a component or an endpoint. If there any other way to do this then please let me know.

Thanks in advance. 

  • AdamN's avatar
    AdamN
    Khoros Oracle

    Hi pp_01 , it looks like your value might be HTML escaped rather than base 64 encoded. Can you tell more about where this SSO ID value is coming from? Are you retrieving it from the REST API, or query parameter, or somewhere else?

    There's no utility to un-escape, but if it's just the @ symbol giving you trouble you could maybe try just a simple ?replace("@","@") on the variable.

    • pp_01's avatar
      pp_01
      Mentor

      Hello AdamN this SSO ID is coming in a JSON as a property value from a GET Response when I'm trying to get the user details for a particular Webhook event.

      <#assign msg_response = http.client.request("${Url}").header("Authorization","Basic ${base64}").header("Accept","application/json").header("Content-Type","application/json").get()/>



      The above code gets me the response and in there that's how it comes - 

      "issuer_earner_id":"cscusers2&#64;gmail.com"

      But the strange thing is when I'm printing the same response in a component then it prints "issuer_earner_id": "cscusers2@gmail.com" properly and even if I want to get it out separately in a variable it is possible for me to do that, but only in a component not in an endpoint though. While printing the response why this character "@" is printing as "&#64;" in the endpoint but not in the component? Also if I'm making the GET call in the console I'm able to get the value cscusers2@gmail.com properly.

      And yes, to replace the @, that is the current option we have as we have tried almost everything to encode it somehow to get the desired result but nothing worked. But our functionality can break if there is any other special character which comes as HTML escaped so we were hoping for an all-around solution.