Forum Discussion

dchou's avatar
8 years ago

LIQL queries and white spaces in freemarker

If I'm in the Studio option and go to the API call (LIQL) i can create a query such as:

 

SELECT * FROM messages WHERE labels.text = "Hello World"

 

This would return results correctly. But if i were to use

 

<#assign x= rest("2.0b","/search?q=" + "SELECT * FROM messages WHERE labels.text = "Hello World"?url) />

 

It would show empty results. I'm assuming this is because the URL renders %20 for the whitespace. Is there anyway to work around this?

Thanks

  • Hi dchou,

     

    I made a slight tweak to your freemarker LiQL call and it worked for me on the site I tested on:

     

    <#assign x = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE labels.text = 'Hello World'"?url) />

    The Query should get URL decoded before it's run, so the url-encoded space should be ok.

     

    Let me know if that changed query works for you or not.

     

    -Doug

  • DougS's avatar
    DougS
    Khoros Oracle

    Hi dchou,

     

    I made a slight tweak to your freemarker LiQL call and it worked for me on the site I tested on:

     

    <#assign x = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE labels.text = 'Hello World'"?url) />

    The Query should get URL decoded before it's run, so the url-encoded space should be ok.

     

    Let me know if that changed query works for you or not.

     

    -Doug

    • dchou's avatar
      dchou
      Ace

      Thanks, I realized later that the i had to decode the %20 and replace it with a space and rerun the query.