Metadata Search API: Failed to parse query: Invalid input '-', expected simpleIdentifierTail or EOI
回答済みHi,
I'am facing issues while using the new metadata search api:
https://api.box.com/2.0/metadata_queries/execute_read
while setting the "from" parameter to look for the securityClassification template, im getting this error:
Here's the full request body
{
"ancestor_folder_id":"value",
"from": "enterprise_ID.securityClassification-6VMVochwUWo",
"query": "Box__Security__Classification__Key = :template",
"query_params": {
"template": "Confidential"
}
}
Seems like the API doesn't allow '-' in the "from" parameter but in this case this is a valid template name.
-
Hi
I'll preface this by saying that Box doesn't currently support querying classifications because it is very likely that you will eventually bump into either:
1. The limit on the number of metadata instances (which is 10,000 - above which we require an index for any query referencing that template)
2. The limit on the number of results your query matches prior to evaluation of user permissions or the location in your folder structure (which is 2,000 - above which we may fail a query an indicate it needs to be more selective).
You can review details about these limits here: https://developer.box.com/guides/metadata/queries/limitations/
Now to the specific issue which is actually related to escaping certain characters. If your
templateKey
or fieldkey
contains a special character (not alphanumeric or underscore), you must quote the string with double quotes and use a backslash to escape these double quotes.In your example, the classification template contains a hypen, which needs to be escaped. The following is the appropriate syntax to do so:
{
"from": "enterprise_myEID.\"securityClassification-someString\"",
...
}As another example, imagine you have a field key with a hyphen, such as a field called
vendor-name
. The resulting query to reference this field would look as follows:"query": "\"vendor-name\" = :name"
Can you share a bit more about what you're trying to do with Classifications and the Query API? There may be an alternative to accomplish your goal. If you don't feel comfortable sharing in
-
Hi ,
Thanks for the solution.
I'm trying to query all the items under a folder which have classification 'A' or 'B' or 'C' etc.....
I'm currently using the search API but it doesn't support logical operators in filters so have to make call for fetching the result for each classification separately.
So i'm trying to use this api now to optimise the number of calls.
-
I am facing a similar challenge.
I want to search for a custom metadata field in this case "issueType" and get a listing for all documents. The use case is to handle file belonging to a certain case while allowing users to organise them i subfolders.
I am using this endpoint:
https://{{api.box.com}}/2.0/metadata_queries/execute_read
{"from": "enterprise_3727xxxxx.contentperspectivemvp0","query": "issueType = :issueType","query_params": {"issueType": "\"Racial Injustice\""},"fields": ["created_at","metadata.enterprise_3727xxxxx.contentperspectivemvp0.issueType","metadata.enterprise_3727xxxxx.contentperspectivemvp0.movementType"],"ancestor_folder_id": "121493081635","order_by": [{"field_key": "created_at","direction": "asc"}],"limit": 50,}I am getting errors like this when running it through Postman with a developer token:{"type": "error","status": 400,"code": "bad_request","context_info": {"errors": [{"reason": "invalid_parameter","name": "entity-body","message": "Invalid value '{\n \"from\": \"enterprise_3727xxxxx.contentperspectivemvp0\",\n \"query\": \"issueType = :issueType\",\n \"query_params\": {\n \"issueType\": \"\\\"Racial Injustice\\\"\"\n },\n \"fields\": [\n \"created_at\",\n \"metadata.enterprise_3727xxxxx.contentperspectivemvp0.issueType\",\n \"metadata.enterprise_3727xxxxx.contentperspectivemvp0.movementType\"\n ],\n \"ancestor_folder_id\": \"121493081635\",\n \"order_by\": [\n {\n \"field_key\": \"created_at\",\n \"direction\": \"asc\"\n }\n ],\n \"limit\": 50,\n}'. Entity body should be a correctly nested resource attribute name/value pair"}]},"help_url": "http://developers.box.com/docs/#errors","message": "Bad Request","request_id": "43wjdbgijvw41yd2"}Anyone know what to do?
サインインしてコメントを残してください。
コメント
5件のコメント