Forum Discussion

leorochasantos's avatar
leorochasantos
Contributor
7 years ago

URL Encoding in API v1 Search Method

Hello All,

 

We've developed an internal tool to allow for user email search based on login and user login search based on email using the Community API v1.

 

When making individual calls, leveraging the below methods, we usually get a successful response regardless or special characters in the parameter:

http://[*community_domain*].com/restapi/vc/users/login/[*user_login_param*]?restapi.session_key=[*session_key*]
http://[*community_domain*].com/restapi/vc/users/email/[*user_email_param*]?restapi.session_key=[*session_key*]

 

However, when trying to leverage the search method, special characters will result in no records found:

http://[*community_domain*].com/restapi/vc/search/users?restapi.session_key=[*session_key*]&f=login&q=[*user_login_param*]&page_size=150

http://[*community_domain*].com/restapi/vc/search/users?restapi.session_key=[*session_key*]&f=email&q=[*user_email_param*]&page_size=150

 

Our idea was using the search method to retrieve multiple results using an OR operator to append multiple parameters and that works fine, but the API is not able to handle non-western characters even after we do proper URL encoding upfront.

 

We are considering refactoring this solution to use the API v2, but users.email is not a constraint allowed in LiQL queries, so we would be able to search only based on logins, which covers just half of our use cases.

 

Would anyone have a suggestion on how to perform bulk search, so we don't need to have single search calls in a loop to bypass the character encoding issue?

 

Thanks!

  • did you try to set the URL encoding global setting for FreeMarker before your code? (if you're using FreeMarker at all...)

     

    <#setting url_escaping_charset = "UTF-8" />

    otherwise I would contact support!

    • leorochasantos's avatar
      leorochasantos
      Contributor

      Hey luk,

       

      Thanks for the reply, but I'm calling the API directly from PL/SQL, so this solution might not be applicable. I'll probably go ahead and contact support.

       

      Best,

       

      Leo