RestSharp multipart request in from Unity fails with NRE after successfully sending request
With this stack trace:
This is what I'm doing:
It actually successfully sends request but immediately throws exception inside. Without attachment it works fine. Am I doing something wrong or is this a bug?
1 Reply
Exactly same request but without multipart works
RestSharp 110.2.0
I'll just post since I figured out what issue was - it's with the System.Net.Http bundled with unity, it has a bug where double dispose on MultipartContent causes NRE because it sets internal list to null in dispose and doesn't check for null before enumerating; this issue isn't present in the reference .NET code and I found it in Unity one by debugging with dnspy
the only way to avoid issue it to directly use HttpClient for multipart requests and avoid doing double dispose (it disposes request itself on send)
this is a bug with assembly bundled with Unity because double dispose is supposed to be safe to do