Forum Discussion

Pradnya's avatar
Pradnya
Guide
7 years ago

Issue due to apostrophe in V2  API

Hi,
V2 API giving an error for following API call:

V2 call:

SELECT * FROM messages WHERE board.id IN('boardIds') AND depth = 0 AND subject MATCHES  'Test For Latest Idea  Somebody's Test' limit 100

 

I tried in code replacing single quotes with double quotes but doesn't get success

  • Pradnya

    I would suggest you hit the query with single board id and hard code value. Like below so it can be confirmed either there is the API issue or syntax issue. 

    Also, use the encoded match term "Test%20For%20Latest%20Idea%20%20Somebody%27s%20Test". 

    <#assign messages= rest("2.0","/search?q=" + "SELECT * FROM messages WHERE board.id IN('ids') AND depth = 0 AND subject MATCHES 'Test%20For%20Latest%20Idea%20%20Somebody%27s%20Test' limit 100"?url) />
    ${messages.data.size}

    It works fine.  https://prnt.sc/j9fg4d

7 Replies

  • Pradnya - Please try below call

    SELECT * FROM messages WHERE board.id IN('ids') AND depth = 0 AND subject MATCHES  "Test For Latest Idea  Somebody's Test" limit 100
  • Pradnya's avatar
    Pradnya
    Guide
    7 years ago
    <#assign queryString = 'SELECT * FROM messages WHERE board.id IN('ids') AND depth = 0 AND subject MATCHES "Test For Latest Idea  Somebody's Test" limit ${liql_limit}' />
    I also tried replacing single quotes by double quotes.
  • Pradnya's avatar
    Pradnya
    Guide
    7 years ago
    I am getting freemarker error on UI side as I am accessing the list came from the response :
    InvalidReferenceException:The following has evaluated to null or missing:
    ==> response_topics.data.size
  • VikasB's avatar
    VikasB
    Boss
    7 years ago

    Pradnya

    I would suggest you hit the query with single board id and hard code value. Like below so it can be confirmed either there is the API issue or syntax issue. 

    Also, use the encoded match term "Test%20For%20Latest%20Idea%20%20Somebody%27s%20Test". 

    <#assign messages= rest("2.0","/search?q=" + "SELECT * FROM messages WHERE board.id IN('ids') AND depth = 0 AND subject MATCHES 'Test%20For%20Latest%20Idea%20%20Somebody%27s%20Test' limit 100"?url) />
    ${messages.data.size}

    It works fine.  https://prnt.sc/j9fg4d

  • VikasB's avatar
    VikasB
    Boss
    7 years ago

    Pradnya

    Nice to see that it resolved your problem. 

    You can use ?url to encode the string if you want to pass the match_term dynamically. 

    <#assign match_term = "Test For Latest Idea  Somebody's Test" />
    <#assign match_term = match_term?url />
    <#assign messages= rest("2.0","/search?q=" + "SELECT * FROM messages WHERE board.id IN('ids') AND depth = 0 AND subject MATCHES '${match_term}' limit 100"?url) />
    ${messages.data.size}