2025 sparked some incredible conversations across our community 👩💻. Discover the highlights and see what’s ahead in 2026.
Forum Discussion
donaldp
3 years agoCollaborator | Level 9
Trying to get dotnet batch upload working (to solve "too many operations" issue)
Hi, I'm saving a lot of log files from parallel process and running into "too many operations" exceptions occasionally (I already rate-limited them to 1 per second start rate to deal with a ra...
Greg-DB
Dropbox Community Moderator
3 years agoFirst, for reference, if there are multiple changes at the same time in the same account or shared folder, you can run in to the 'too_many_write_operations' error, which is "lock contention". That's not explicit rate limiting, but rather a result of how Dropbox works on the back-end. 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/team folder preventing your app from making the state-modifying call (e.g., adding, editing, moving, copying, sharing, or deleting files/folders) it is attempting. The simultaneous activity could be coming from your app itself, 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.
In short, to avoid this error, you should avoid making multiple concurrent state modifications and use batch endpoints where 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 should also implement error handling and automatic retrying as needed.
I also recommend referring to the error documentation and Error Handling Guide for more information.
Looking at your code, I see you are using UploadSessionFinishBatchAsync to commit multiple files in a batch, which is good and can help avoid lock contention. Likewise though, make sure you're only running one WriteBatchOfFilesAsync at a time though (that is, effectively one UploadSessionFinishBatchAsync job at a time), otherwise they may conflict with each other.
Also, the offset for any particular upload session (that is, for any particular file that you're uploading), should be however much data you've uploaded to that upload session for that file so far. So, unless you are intending to exclusively upload empty files, you should not be setting your offset to 0 as you have in this code, nor should you be setting it to the current size of the file on the Dropbox servers, if any, as you have in the commented out version of the code. Since you're just using one UploadSessionStartAsync call per file, it would be the size of the file data you're passing to that, which you have as StringToStream(file.Content). (Also, make sure StringToStream(file.Content) is returning the data you expect it to.)
Once you do have UploadSessionFinishBatchJobStatus.Complete, you should check each UploadSessionFinishBatchResultEntry in UploadSessionFinishBatchResult.Entries, to see whether each one succeeded or failed, and why.
donaldp
3 years agoCollaborator | Level 9
Hi Greg,
> check each UploadSessionFinishBatchResultEntry in UploadSessionFinishBatchResult.Entries, to see whether each one succeeded or failed, and why
Where do I get the UploadSessionFinishBatchResult from? What do I call? I don't see it being returned by anything I'm calling, and can't see any mention of what to call to get it. https://dropbox.github.io/dropbox-sdk-dotnet/html/T_Dropbox_Api_Files_UploadSessionFinishBatchResultEntry.htm doesn't say what it's called/returned by
- Greg-DB3 years ago
Dropbox Community Moderator
The UploadSessionFinishBatchCheckAsync method returns UploadSessionFinishBatchJobStatus, and once UploadSessionFinishBatchJobStatus.IsComplete is true, you can use UploadSessionFinishBatchJobStatus.Complete to access UploadSessionFinishBatchJobStatus.Complete.Value which is UploadSessionFinishBatchResult, to access UploadSessionFinishBatchResult.Entries which is a list of UploadSessionFinishBatchResultEntry.
- donaldp3 years agoCollaborator | Level 9
Oh ok. I didn't realise it went deeper than "IsComplete"! Thanks! Have a good Easter Greg.
- donaldp3 years agoCollaborator | Level 9
Hey Greg,
I've ALMOST got this one licked. I got down to "too many write operations", and I single-streamed UploadAsync and my batch writes through a lock file, and was working, working, working, then bam, all of a sudden got another couple of "too many write operations", and I'm like "Huh? How can that be when I'm single-streaming my writes?", so I'm guessing something else is counting as a write.
So, could you let me know what operations count as writes? I've got UploadAsync and batch uploads already, and obviously ReadFileAsync isn't a write, but what about, for example, CreateFolderAsync? Or SaveUrlAsync? I need to know what all such "write" methods would be so that I can pipe all of them through my write lock.
thanks,
Donald.
- Greg-DB3 years ago
Dropbox Community Moderator
Yes, any change at all will count as a write, such as adding, editing, moving, copying, sharing, or deleting files or folders, by any means (such as the Dropbox API, web site, client, etc.). That will include both CreateFolderAsync and SaveUrlAsync, but not Download.
About 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!