cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

HTTP API Throttling?

Explorer | Level 3

Hi, I am using the http API to upload files into my account, however >50% of them fail and I suspect it is because I can have up to 20 parallel processes trying to upload in a window of about 5 seconds.

 

Error message: 

{"error_summary": "too_many_write_operations/", "error": {"reason": {".tag": "too_many_write_operations"}}}



Is there a rate limit documented somewhere so I can ensure 100% upload? I understand there is a 1 million API calls/month limit which I won't even get remotely close to. We want to upload files in this manner maybe 2-4 times a month.

Here is the upload php code.

 

$accessToken = "xxxxxxxxxxxx";
$path = $_POST['fileName'];
$fp = fopen($path, 'rb');
$size = filesize($path);

$cheaders = array('Authorization: Bearer '. $accessToken,
                  'Content-Type: application/octet-stream',
                  'Dropbox-API-Arg: {"path":"/images/'.$path.'", "mode":"add"}');

$ch = curl_init('https://content.dropboxapi.com/2/files/upload');
curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, $size);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

curl_close($ch);
fclose($fp);

 

3 Replies 3
Highlighted

Re: HTTP API Throttling?

Dropboxer
Dropboxer

This can happen when attempting to upload multiple files at once. The 'too_many_write_operations' error indicates "lock contention". That's not explicit rate limiting, but rather a result of how Dropbox works on the backend. This is a technical inability to make a modification in the account or shared folder at the time of the API call. This error indicates that there was simultaneous activity in the account or shared folder preventing your app from making the state-modifying call (e.g., adding, editing, moving, or deleting files/folders) it is attempting. The simultaneous activity could be coming from your app itself (as in this case when uploading multiple files in parralel), or elsewhere, e.g., from the user's desktop client. It can come from the same user, or another member of a shared folder. You can find more information about lock contention here:

https://www.dropbox.com/developers/reference/data-ingress-guide

In short, to avoid this error, you should avoid making multiple concurrent state modifications. E.g., don't issue multiple such requests at a time, and use batch endpoints whenever possible. That won't guarantee that you won't run in to this error though, as contention can still come from other sources, so you may also want to implement automatic retries in your app.

Highlighted

Re: HTTP API Throttling?

Explorer | Level 3

Thanks Greg.

I'm just now learning Dropbox's API. What are the endpoints for batch upload? Is it the upload_session EP? If there are some code samples, that would be great. Thanks.

Highlighted

Re: HTTP API Throttling?

Dropboxer
Dropboxer
Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?