We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.
Forum Discussion
MapTiler
8 years agoExplorer | Level 3
API rate limit error
Hi all, I'm using SwiftyDropbox in a Swift 3 app. I managed to get authentication working, I can get the details of the authenticated user, I can upload files, I can download files, I can create ...
Greg-DB
Dropbox Staff
Hi, I'll be happy to help with this. Can you share the relevant code snippets and the error output you're getting specifically so I can take a look? Thanks in advance!
MapTiler
8 years agoExplorer | Level 3
Hi Greg,
Sure: take the createFolder function from your API and call it a hundred times in a for-loop.
That's all the code you need to simulate.
- Greg-DB8 years agoDropbox StaffThere are a few different errors you might be getting depending on the specifics of the scenario, so please share the specific code and error output you are getting so I can offer help with the particular issue you're running in to. Thanks in advance!
- MapTiler8 years agoExplorer | Level 3
Hi Greg,
You have all the information you need to know to reproduce the problem:
- SwiftyDropbox
- loop a couple of 100 times over your createFolder call
- log the errors from the response callback (response part will be nil, error part will be filled with the error)
- Again, the error = API RATE LIMIT ERROR with a retry_after = 1 in the json reply
That's it.
Storing files is your business, yes? Your API apparently won't let me do that without errors. Asking for source code for something that should be working out of the box in the firstplace is getting downright annoying.
You *know* how to simulate it because I've told you ... twice.
Right now the customer is considering moving away completely from Dropbox. So are we going to get a reply from you or do we move away?
- Greg-DB8 years agoDropbox Staff
Thanks for following up. There are multiple different rate limit errors you might get, so I asked for the specific error so that I can make sure I offer the right information.
Specifically, with SwiftyDropbox, a RateLimitError will have a RateLimitReason which can be either tooManyRequests or tooManyWriteOperations.
For 100 calls, I wouldn't expect you to be getting tooManyRequests, but if you are, please let me know as that would likely be a bug. (I did try simulating this by making 100 create folder calls in a loop, but I didn't run in to any errors.)
More likely, I suspect you're getting tooManyWriteOperations. This isn't an imposed rate limit exactly, but rather a technical inability to make multiple modifications at the same time. This is "lock contention", and you can find more information on it in the data ingress guide. The simultaneous activity can be coming from your own app, or from any other source on the user's account, such as other API apps, the official clients, etc.
The way to handle this is the same though. Your app should just retry after the specified Retry-After time.
One optimization you may be able to make however, is to forgo the create folder calls entirely. If you're uploading files to paths where the parent folders don't already exist, you don't need to make the create folder calls. You can just send the upload calls and the parent folders will be automatically created.
Hope this helps!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,875 PostsLatest Activity: 4 hours agoIf 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 or Facebook.
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!