I have a stored procedure which takes a parameter of a document array. I am getting into situations where I send too many documents at once and am getting a "Request size is too large" exception. I could easily avoid this by just calling the stored procedure multiple times with smaller sets of data until all is done. My question is, using the SDK, how can I determine the size of the data I am about to send to the stored procedure before calling it? Ideally I want to send as many documents as possible in one call without going over this limit. I could just make this number something low and realistic, say 10, but what if these 10 documents are so large themselves that the exception will still occur. Some cases I could send 200 and be fine, while others I can only send 5.
In order to find the exact size, you can construct the array, use JsonConvert.SerializeObject(arr) to get the string representation, then find the size sent over the wire using Encoding.UTF8.GetBytes(s).
Ok thanks. This is what I was planning, I just wanted to confirm that JsonConvert.SerializeObject was all I needed to check. I assume I'll need to pad it a little bit for other parts of the request as well (headers and such).
For anyone interested in the solution:
https://github.com/bitwarden/core/commit/79f9f60a78e90970bd33da36e2c1bffc6d2ce867
https://github.com/bitwarden/core/blob/79f9f60a78e90970bd33da36e2c1bffc6d2ce867/src/Core/Repositories/DocumentDB/CipherRepository.cs
https://github.com/bitwarden/core/blob/79f9f60a78e90970bd33da36e2c1bffc6d2ce867/src/Core/Repositories/DocumentDB/Utilities/DocumentDBHelpers.cs
I'm getting this problem as well...
Most helpful comment
For anyone interested in the solution:
https://github.com/bitwarden/core/commit/79f9f60a78e90970bd33da36e2c1bffc6d2ce867
https://github.com/bitwarden/core/blob/79f9f60a78e90970bd33da36e2c1bffc6d2ce867/src/Core/Repositories/DocumentDB/CipherRepository.cs
https://github.com/bitwarden/core/blob/79f9f60a78e90970bd33da36e2c1bffc6d2ce867/src/Core/Repositories/DocumentDB/Utilities/DocumentDBHelpers.cs