"Missing content-type boundary" sending file
See original GitHub issueI’m currently switching from an AutoRest generated client to an Nswag generated c# client. Everything seems to be working except for uploading to IFormFile parameters. There are two problems.
First, here is the swagger:
/ api / Test / UploadFile: {
post: {
tags: [
"Test"
],
parameters: [{
name: "file",
schema: {
type: "file"
}
}
],
requestBody: {
content: {
multipart / form - data: {
schema: {
type: "object",
properties: {
ContentType: {
type: "string"
},
ContentDisposition: {
type: "string"
},
Headers: {
type: "object",
additionalProperties: {
type: "array",
items: {
type: "string"
}
}
},
Length: {
type: "integer",
format: "int64"
},
Name: {
type: "string"
},
FileName: {
type: "string"
}
}
},
encoding: {
ContentType: {
style: "form"
},
ContentDisposition: {
style: "form"
},
Headers: {
style: "form"
},
Length: {
style: "form"
},
Name: {
style: "form"
},
FileName: {
style: "form"
}
}
}
}
},
responses: {
200: {
description: "Success"
}
}
}
},
The first problem is that the generated client method has both a “body” parameter and a “file” parameter. I would expect just one… and browsing through the generated code, it looks like the “file” parameter is not even used.
public async System.Threading.Tasks.Task UploadFileAsync(FileParameter file = null, System.IO.Stream body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
Second, when I try to use this method, I get an error from Asp.Net Core 3.0:
Missing content-type boundary.
This API operation worked fine with the AutoRest generated client, so I just need to figure out what I need to do differently to get the NSwag generated client to work here.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
ASP.NET Core 2 - Missing content-type boundary
Check upload request in developer tools network tab, it should have correct format (matching 'Content-Type': 'multipart/form-data' ) ...
Read more >Error on trying to add files to the transaction in Postman
Symptoms When trying to perform the request to add files to the ... add files to the transaction in Postman: Missing content-type boundary....
Read more >File upload Content-Type header is missing boundary ...
Describe the bug multipart/form-data requests with are missing "boundary" in the Content-Type header To Reproduce Given this OpenAPI ...
Read more >Content-Type boundary issue when uploading a file
I have a chrome extension that is using backendless to upload a file. The code is : var request = new XMLHttpRequest(); request.open('POST', ......
Read more >Multi-part missing boundary problem, while upload an ...
Hi, I have some issue with JMeter 3.2 r 1790748. When I create an HTTP Request to POST image file to the server...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Workaround https://github.com/RicoSuter/NSwag/issues/2419#issuecomment-818433921
In my case, it was the package version. Fixing that solved it.