Box: Delete File
Deletes files on Box. You can delete multiple files at once. When you delete multiple files, you should write one file ID per line.
Configs: Common
  • Step Name
  • Note
  • C1: OAuth2 Setting *
  • C2: Data Item with File IDs to delete *



See also

Intermediate Error Catch Event (Boundary Type)

Script (click to open)
  • An XML file that contains the code below is available to download
    • box-file-delete.xml (C) Questetra, Inc. (MIT License)
    • If you are using Professional, you can modify the contents of this file and use it as your own add-on

function main(){
  const fileIds = engine.findDataByNumber(configs.get("conf_FileIds"));
  if (fileIds === "" ||fileIds === null){
    throw "File IDs aren't set.";

  let linesArray = fileIds.split("\n");
  linesArray = linesArray.filter(lines => lines !== ""); // 空文字列を削除
  if (linesArray.length === 0) {
    throw "File IDs aren't set.";

  const numOfLines = linesArray.length;
  if (numOfLines > httpClient.getRequestingLimit()){
  	throw "Number of File IDs is over the limit."
  const oauth2 = configs.get("conf_OAuth2");
  for (let i = 0; i < numOfLines; i++){
    deleteFile(oauth2, linesArray[i])

function deleteFile(oauth2, fileId) {
  const url = `${fileId}`;

  const response = httpClient.begin()
  const status = response.getStatusCode();
  const responseTxt = response.getResponseAsString();
  engine.log(`status: ${status}`);
  if (status >= 300) {
    throw `Failed to delete File ID:${fileId}`;
    engine.log(`Succeeded to delete File ID:${fileId}`);

%d bloggers like this: