-
-
Notifications
You must be signed in to change notification settings - Fork 447
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
[BUG] JSON payload not parsed when using upload with extra fields #1306
Comments
To disambiguate some code here:
|
For some extra context I use |
I was able to successfully make the request go through via the OpenAPI docs page. The payload looks a lot different:
I think that means that the typescript-fetch plugin for openapi-generator-cli may be the problem. It sends an extra |
Yeap, and found the bug on openapi-generator that's been open since 2020 |
so, they do this in every generator plugin. I think that's what's messing up the parsing and typing here. |
I have same problem, but I am not using openapi-generator |
I tried sending the request not through my application, but through Postman. I noticed that in the request that is processed correctly, the Content-Type header contains a boundary (an arbitrary string that defines the boundaries of the content). b'-----------------------------409722013720178429992086406357\r\nContent-Disposition: form-data; name="file"; filename="\xd0\x9a\xd0\xbe\xd0\xbd\xd1\x82\xd0\xb8\xd0\xbd\xd0\xb5\xd0\xbd\xd1\x82\xd0\xb0\xd0\xbb\xd1\x8c (2).xls"\r\nContent-Type: application/vnd.ms-excel\r\n\r\n\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1\x00\x00\x00\x00\x00... In this case, -----------------------------409722013720178429992086406357 is our boundary, which can be found at the beginning and end of the raw request. The method django.http.multipartparser.MultiPartParser.init looks for the boundary in the Content-Type and expects the following format in the request headers: When explicitly setting a value for Content-Type, using fetch does not automatically substitute the boundary value. |
Describe the bug
Ninja fails to parse the request body correctly and throws a validation error, contrary to the instructions under Upload files with extra fields.
Versions (please complete the following information):
Relevant schema
API Code
Request body
Content-Type
on the request is set tomultipart/form-data; boundary=---------------------------291645760626718691221248293984
Response
The text was updated successfully, but these errors were encountered: