Skip to main content
Question

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

  • May 22, 2025
  • 6 replies
  • 51 views

Forum|alt.badge.img

I can't perform a search using metadata. It wants a scope that I can't provide. Here's what I did:

 

1. Create a template:

 

var template = new BoxMetadataTemplate
{
    DisplayName = "Folder Management",
    TemplateKey = "folderManagement",
    Scope = "enterprise",
    Fields = Fields // defined elsewhere
};
client.MetadataManager.CreateMetadataTemplate(template).Wait();

 

 

2. Save metadata:

 

await boxClient
    .MetadataManager
    .SetFolderMetadataAsync(
        folderId: folderId, // defined elsewhere
        metadata: metaData, // defined elsewhere
        scope: "enterprise",
        template: "folderManagement"
    );

 

 

 3. Search using metadata:

 

var searchResults = await boxClient.MetadataManager.ExecuteMetadataQueryAsync(
    from: "enterprise.folderManagement", // this is the issue
    ancestorFolderId: "0",
    query: "managers IS NOT NULL",
    queryParameters: new Dictionary
    {
        { "userEmail", userEmail }
    }
);

 

 

4. Get Error:

BoxException: The API returned an error [BadRequest | nte3svgf6fuxyq0k.0294efea317bc791862ab534ff2055d79] invalid_query - Failed to parse query: Invalid input '.', expected simpleIdentifierTail (line 1, pos 11):
enterprise.folderManagement

^

6 replies

Forum|alt.badge.img

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"
}

Forum|alt.badge.img

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.


Forum|alt.badge.img

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.


Forum|alt.badge.img

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." 


Forum|alt.badge.img

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",
...
}

 

 


Forum|alt.badge.img

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.