- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
In multipart form, JSON part is missing the JSON content type in the content disposition header #1716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
All working now, changed the line
request.Form now contain the posted json data |
Have you followed the bug report issue template? We ask to trace both working and non-working requests, so it's possible to see the difference. |
Sorry I did not, but can do later on if you wish |
Here is what I found. RS 106 JSON data:
RS 107:
Apparently, the content type for the JSON form part is not set properly in the content disposition header. I'll look into it. |
No, I think I wrote some rubbish. The content type is correct. The only difference is that the part name is not set to "application/json", which doesn't seem to be any kind of requirement. Nevertheless, I must've been there for a reason to use the body parameter content type as the content disposition form part name. Looks weird to me, but who knows. The 107.1.2-alpha.0.10 sets it as before, you might want to try it out. |
Hi, Upgraded to 107.1.2-alpha.0.18 now I get a different error, when calling client.ExecuteAsync(request).Result; Message = "The type initializer for 'RestSharp.HttpContentExtensions' threw an exception." Message = "Instance field '_boundary' is not defined for type 'System.Net.Http.MultipartContent'" at RestSharp.HttpContentExtensions.GetFormBoundary(MultipartFormDataContent content) |
It seems to be platform-specific. I expected it, the old code is still in place. The issue is that the I am considering replacing the boundary generated by the content class with another GUID that I can keep and access. It should resolve the issue. |
And, I think you are not on .NET 5 or 6, right? |
correct, we are currently using .NET 4.7.2 to test the API, |
Ok, it's better than I thought. It's possible to provide the boundary value instead of letting the content generate it. |
I removed all the stuff with reflections, plus it's now possible to override the boundary if necessary. All good. Please try the next alpha when it gets published, it will take a few minutes. |
I expect that after all the changes those requests will be identical, except the charset in the content type. If it still won't work, you can try eliminating the charset by setting |
Any news? |
all works as expected, thanks |
Describe the bug
Request.Form containd no data
To Reproduce
client side
server side
Expected behavior
Stack trace
There is not stack trace for this issue. Except behaviour has changed
after upgrading from 106.13.0 to 107.1.1
106.13.0 -> Request.Form contains key called 'application/json'
107.1.1 -> Request.Form no data
Desktop (please complete the following information):
OS: Windows 10
.NET version 4.7.2
Version: 107.1.1
Additional context
workaround
changed request.AddJsonBody(jsonData) ->request.AddParameter("application/json", JsonConvert.SerializeObject(jsonData));
has resolved the issue in 107.1.1
The text was updated successfully, but these errors were encountered: