Forum Discussion

PAULEM's avatar
PAULEM
Advisor
6 years ago

Bug report - LiQL JSON response

In the API Browser (STUDIO) I entered

SELECT * FROM custom_tags WHERE messages.id = '2867'

This returned a JSON response:

{
  "status" : "success",
  "message" : "",
  "http_code" : 200,
  "data" : {
    "type" : "custom_tags",
    "list_item_type" : "custom_tag",
    "size" : 1,
    "items" : [ {
      "type" : "custom_tag",
      "id" : "1046",
      "href" : "/custom_tags/1046",
      "text" : "Certified",
      "messages" : {
        "query" : "SELECT * FROM messages WHERE custom_tag.id = '1046'"
      }
    } ]
  },
  "metadata" : { }
}

I copied the messages.query SELECT statement offered by this response and pasted it into the API Browser box:

SELECT * FROM messages WHERE custom_tag.id = '1046'

This returned an error with this message:

{
"status" : "error",
"message" : "invalid query syntax for SELECT * FROM messages WHERE custom_tag.id = '1046'",
"data" : {
"type" : "error_data",
"code" : 604,
"developer_message" : "Field 'custom_tag' is not a valid constraint for the object 'messages' (there is no field named 'custom_tag'). in: SELECT * FROM messages WHERE custom_tag.id = '1046'",
"more_info" : ""
},
"metadata" : { }
}

Since "there is no field named 'custom_tag'..." I tried it with 'custom_tags' ('s' on the end) and received this error message:

{
  "status" : "error",
  "message" : "invalid query syntax for SELECT * FROM messages WHERE custom_tags.id = '1046'",
  "data" : {
    "type" : "error_data",
    "code" : 604,
    "developer_message" : "'custom_tags.id' is not a valid constraint for the object 'messages'. in: SELECT * FROM messages WHERE custom_tags.id = '1046'",
    "more_info" : ""
  },
  "metadata" : { }
}

So, custom_tags (with an 's') is a field in the messages collection -- you should fix the typo in the messages.query field

But you cannot use the SELECT statement!  The offer of a messages.query statement should not be made if the statement won't work!

For your consideration ...

Paul (Hobart, Tasmania)

  • PAULEM 

    Here is something Lithium needs to heads up to correct the error text. Actually, the constraint is there in the API but unfortunately, custom_tags.text is not working with id.  You can pass the tag's key value instead of id. You can get the tag key at the edit screen of the custom tag. See here https://prnt.sc/mi84fu
    Like this

    SELECT * FROM messages WHERE custom_tags.text = 'custom.tag.value'


    But if you want to play with tag id only then you have to go with V1 API

    http://community.com/restapi/vc/posts/for/metadata/id/1046/value/true

     

  • PAULEM 

    Here is something Lithium needs to heads up to correct the error text. Actually, the constraint is there in the API but unfortunately, custom_tags.text is not working with id.  You can pass the tag's key value instead of id. You can get the tag key at the edit screen of the custom tag. See here https://prnt.sc/mi84fu
    Like this

    SELECT * FROM messages WHERE custom_tags.text = 'custom.tag.value'


    But if you want to play with tag id only then you have to go with V1 API

    http://community.com/restapi/vc/posts/for/metadata/id/1046/value/true

     

    • PAULEM's avatar
      PAULEM
      Advisor

      Thanks VikasB 

      Your snippet of advice is GOLD - just what I needed to do what I want to do!  I reported this bug to highlight this error and didn't expect an answer so thank you (and Parshant) very much for looking at this.

      Cheers, PaulM

  • PAULEM ,

    Error you are facing is not about 'custom_tag' or 'custom_tags'.  Error is showing due to constraints, there is no constraint available with 'custom_tags.id', which means you can not use this in where clause. To your solution you can use 'custom_tags.text' to get the message.

    See all related documents here for the message.