Welcome to the new Box Support website. Check out all the details here on what’s changed.

invalid_query - Failed to parse query: Invalid input '.', expected simpleIdentifierTail

Answered
New post

Comments

6 comments

  • Mac_Dayao

    I got the same error using postman to test the API.

     

    Send JSON data:

    {
    "from": "enterprise.TEST",
    "query": "TEST = :value1",
    "query_params": {
    "value": "boxworks"
    },
    "ancestor_folder_id": "0"
    }

     

    Receive JSON data:

    {
        "message""Failed to parse query: Invalid input '.', expected simpleIdentifierTail (line 1, pos 11):\nenterprise.TEST\n          ^\n",
        "code""invalid_query",
        "request_id""4zk6ucgf6qq1fay5"
    }
    0
    Comment actions Permalink
  • dandennhardt

    There are a few things in the JSON that I believe need to be corrected.

     

    1. The template name in the "from" argument should be fully qualified with an enterprise id in the form `scope.templateKey`. The likely value is enterprise_yourEnterpriseId.templateName. You can get this for sure by listing enterprise templates via API and looking at the the scope and templateKey fields.

     

    2. The name of your parameter in the `query_params` argument does not match the name in the `query` argument. You have "value" in the params, but "value1" in the query. These must be identical.

     

    Here is an example of a valid POST body from Postman:

    {
    "from": "enterprise_240748.catalogImages",
    "query":"photographer LIKE :name",
    "query_params": {
    "name":"Dan"
    },
    "ancestor_folder_id": "0",
    "limit":1
    }

     

    See if that solves the problem.

    0
    Comment actions Permalink
  • dandennhardt

    I'm not familiar with the specific syntax of the SDK you're using, but please see my reply to the post by  as it shares several things in common with yours, including what I believe is an incorrect template scope and a mismatch between the `query` and `query_params` arguments.

    0
    Comment actions Permalink
  • YousefShanawany

    Thanks . I'll give this a try.

    But if I need to have an enterprise ID, then why was there no error thrown when I created a template? When I created a template, the scope was just "enterprise." 

    0
    Comment actions Permalink
  • dandennhardt

    Good question - Box generates the fully qualified scope when you create the template, you do not assign it specifically. If you do do a GET request on your template, you should be able to identify the fully qualified scope. More information on the template definition is available at https://developer.box.com/reference/resources/metadata-template/

     

    Here's an example of a truncated response to a GET request on a template by name.

    {
        "id""6128f626-98aa-4765-someMoreDigits",
        "type""metadata_template",
        "templateKey""catalogImages",
        "scope": "enterprise_2555555",
        "displayName""Catalog Images",
    ...
    }

     

     

    0
    Comment actions Permalink
  • YousefShanawany

    Thanks. I was able to find my created templates. Even though I set the scope to "enterprise," I was able to get a list of the templates with an actual enterprise with a numberic ID. Pretty confusing but it worked. 

    0
    Comment actions Permalink

Please sign in to leave a comment.