question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Missing content-type boundary" sending file

See original GitHub issue

I’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:open
  • Created 4 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
marinasundstromcommented, May 20, 2022

In my case, it was the package version. Fixing that solved it.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found