invalid_query - Failed to parse query: Invalid input '.', expected simpleIdentifierTail
回答済み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^
-
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"} -
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.
-
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",...}
サインインしてコメントを残してください。
コメント
6件のコメント