Forum Discussion

philip-lf's avatar
philip-lf
Explorer | Level 4
8 years ago

Files Delete batch

 

dbx.filesListFolder({path: '/app', recursive: true})
    .then(response => {

      let path = response.entries.map(entry => {
        return {path: entry.path_lower};
      })
 
      dbx.filesDeleteBatch({entries: path})
      .then(response => {
        console.log(response);
      })
    })

Hi there, I am trying to delete several files/folders at once, however, when I use the 'filesDeleteBatch' method it does not delete anything. Its response in the '.then()' looks like this: 

{ '.tag': 'async_job_id', async_job_id: '...idNumber...' }

How can i solve this problem?

Thank you

 

3 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    The filesDeleteBatch method does not necessarilly immediately delete the requested files. It can create and return the ID for an asynchronous job.

     

    You should use the filesDeleteBatchCheck method, supplying the async job ID you received from filesDeleteBatch, to check on the job's status. If the job failed, it will indicate why.

  • buttflattery's avatar
    buttflattery
    Explorer | Level 4
    7 years ago

    so this means that we need to periodically check manually by sending the hit to `delete_batch/check` API endpoint. 

    Isnt there any way that we can use webhook against the delete_batch which should automatically submit the payload to the given URL?

    This feature can be useful.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago

    buttflattery Yes, when the API returns an async job like this, you'll need to use the relevant endpoint to periodically check the status of the job until it's done.

    The Dropbox API doesn't offer webhook functionality for this, or any other way to be automatically notified of async job status changes, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!