✅ Content would exceed Content-Length
I have this code to add files to an
HttpClient
to send API requests to an external API.
The problem I have, is that I am getting the error Unable to write content to request stream; content would exceed Content-Length
. Now, in some cases, the automated Content-Length
value being set was incorrect. I have tried manually setting the content length with streamContent.Headers.ContentLength = fileStream.Length
and while this does correctly set the size, I still get the same error that it would exceed the length. I'm not sure why that's occurring.2 Replies
Figured out my problem. I was clearing my
_fileStreams
, but I needed to also _formData.Dispose()
and then create a new object.If you have no further questions, please use /close to mark the forum thread as answered