问题
I need working sample codes for delete a folder and list all items + folders in the root. I use node.js and as example I can create folder with
client.folders.create('0', 'New Folder', function(err, newFolder) {
if(err) throw err;
console.log('dff')
});
But if I try then related to docs client.folders.delete
client.folders.delete('0', 'New Folder', function(err, newFolder) {
if(err) throw err;
console.log('dff')
});
I get error "Unexpected API Response [403 Forbidden] (access_denied_insufficient_permissions: "Access denied - insufficient permission")". If I would remove 0 then I get rejection error.
回答1:
var client = sdk.getAppAuthClient('enterprise', ENTERPRISE_ID);
client.folders.getItems('0', null, function(err, items) {
items.entries.forEach(function(element) {
console.log(element)
if (element.type == 'folder') {
console.log('folder: ' + element.type);
client.folders.delete(element.id, {recursive: true}, function(err, data) {
});
}
else {
console.log('file: ' + element.type);
client.files.delete(element.id, {recursive: true}, function(err, data) {
});
}
}, this);
})
来源:https://stackoverflow.com/questions/45517682/box-api-node-js-how-to-delete-folder-and-display-all-files-inclusive-folders