
Box: フォルダ削除 (Box: Delete Folder)
この工程は、Box 上のフォルダを削除します。一度に複数の削除が可能です。
Notes
- フォルダ ID は、URL に含まれています。 https:// {sub-domain}.app.box.com/folder/(Folder ID)
- Box のリフレッシュトークンには、期限があります。期限を超えないよう、定期的に利用する必要があります。(Box: トークンおよびURLの有効期限)
Capture

See also
Script (click to open)
- 次のスクリプトが記述されている XML ファイルをダウンロードできます
- box-folder-delete.xml (C) Questetra, Inc. (MIT License)
- Professional のワークフロー基盤では、ファイル内容を改変しオリジナルのアドオン自動工程として活用できます
function main() {
const folderIds = engine.findDataByNumber(configs.get("FolderIdsItem"));
if (folderIds === "" || folderIds === null) {
throw "Folder IDs aren't set.";
}
let linesArray = folderIds.split("\n");
linesArray = linesArray.filter(lines => lines !== ""); // 空文字列を削除
if (linesArray.length === 0) {
throw "Folder IDs aren't set.";
}
const numOfLines = linesArray.length;
if (numOfLines > httpClient.getRequestingLimit()) {
throw "Number of Folder IDs is over the limit."
}
const oauth2 = configs.getObject("OAuth2");
for (let i = 0; i < numOfLines; i++) {
deleteFolder(oauth2, linesArray[i])
}
}
function deleteFolder(oauth2, folderId) {
const url = `https://api.box.com/2.0/folders/${folderId}`;
let response = httpClient.begin()
.authSetting(oauth2)
.queryParam("recursive", "true")
.delete(url);
const status = response.getStatusCode();
const responseTxt = response.getResponseAsString();
if (status >= 300) {
engine.log(responseTxt);
throw `Failed to delete. Folder ID:${folderId}, status: ${status}`;
} else {
engine.log(`Succeeded to delete. Folder ID:${folderId}`);
}
}