Deleting Box Folder using Box name
Hi,
I want to delete the Box folder and what i have is Box Folder Name and i also have its parenet folder name.
How can i get the box id by its name?
Regards
PK
-
You can search for a folder by name using the Search endpoint. You can limit the search results to just folders by setting the type parameter to folder.
Once you have the folder id, you can use the Delete Folder endpoint.
-
Using 's example, I tested this out and it seems to work...
BoxSearchParameters boxSearchParameters = new BoxSearchParameters("ken"); // search by name boxSearchParameters.setType("folder"); // only return folders BoxSearch boxSearch = new BoxSearch(userAPI); List parentFolderId = new ArrayList<>(); parentFolderId.add("0"); boxSearchParameters.setAncestorFolderIds(parentFolderId); PartialCollection results = boxSearch.searchRange(0, 10, boxSearchParameters); for (Iterator iterator = results.iterator(); iterator.hasNext(); ) { BoxItem.Info info = iterator.next(); System.out.println(info.getName() + " [" + info.getID() + "]"); BoxFolder boxFolder = (BoxFolder)info.getResource(); boxFolder.delete(true); }
サインインしてコメントを残してください。
コメント
2件のコメント