Hey all
I’m trying to use the Box Typescript SDK’s `client.search.searchForContent()` method to query for Folders using `tags`.
There are two routes that I tried, both did not result in success, so was hoping someone knows what’s going on. The two routes were:
Update Folder `tags` property:
- on Folder Create, add step which calls PATCH Folder (`client.folders.updateFolderById`) and update `tags` property
-
const folder = await this.scopedClient.folders.updateFolderById(
folderId,
{
requestBody: {
tags: tags
},
}
); - oddly, when I GET Folder after this PATCH, I don’t see the “tags” attribute defined (ie: `tags: undefined`). I tried the same call, with both `name` and `tags`, and still, `tags` was not updated, however `name` was updated and changed
-
- when query’ing, add to query params `query: {tags}`
-
const searchResults = await this.scopedClient.search.searchForContent({
contentTypes: 'tags',
query: tags.join(' '),
type: 'folder',
fields: 'id', 'name'],
ancestorFolderIds: parentfolderId,
});
-
- though querying for tags here should result in h] since `tags` wasn’t updated (or it was in a nested attribute?)
Create Folder Metadata:
- on Folder Create, add step which calls POST FolderMetadata `client.folderMetadata.createFolderMetadataById()`
-
const folderMetadata = await this.scopedClient.folderMetadata.createFolderMetadataById(
folderId,
'global',
'properties',
{
'tags']: tags 0],
},
); - again, this had a similar issue as the PATCH Folders, in that the `metadata` attribute was `undefined`, though the FolderMetadata instance was created
-
- when query’ing, add to query params `mdfilters: {filters}`
-
(the ‘tags’ value here was hard-coded for testing purposes)const searchResults = await this.scopedClient.search.searchForContent({
mdfilters: /
{
scope: 'global',
templateKey: 'properties',
filters: {
{'tags']: 'tax_docs'
}
}
],
type: 'folder',
fields: b'id', 'name', 'type'],
ancestorFolderIds: parentfolderId,
limit: 200 // Add reasonable limit
});
-
Bad Request:
- in both cases, I’d get the error `400: Bad Request`, with no information on why they were Bad Requests.
Any help would be appreciated. We would like to add `tags` to our Folders in some capacity.