Unexpected end of MIME multipart stream. MIME multipart message is not complete. Web API and superagent

readasmultipartasync unexpected end of mime multipart stream. mime multipart message is not complete
unexpected end while searching for first mime boundary
postman unexpected end of stream, the content may have already been read by another component
asp.net web api file upload and multipart mime
error reading mime multipart body part
did not find required 'content-disposition header field in mime multipart body part
read multipart/form-data c#
ismimemultipartcontent

I have a problem with uploading files from client to web api. I am getting this error "Unexpected end of MIME multipart stream. MIME multipart message is not complete." in the controller when i am trying to read the multipart content. I ma building an React JS client with superagent and this is my code for the request:

 UploadFiles(files: File[]): Promise.IThenable<any> {

    return this.Post("/Payment/files" , {
        data: {
            files: files
        },
        headers: {
            "Content-Type": "multipart/form-data; boundary=gc0p4Jq0M2Yt08jU534c0p",
            "Content-Disposition": "form-data; name=Foo",
        }
    });
}

And this is my controller code:

[Route("files")]
[HttpPost]
public async Task<HttpResponseMessage> UploadFiles()
{
        string root = Path.GetTempPath();
        var provider = new MultipartFormDataStreamProvider(root);

        Stream reqStream = Request.Content.ReadAsStreamAsync().Result;
        MemoryStream tempStream = new MemoryStream();
        reqStream.CopyTo(tempStream);

        tempStream.Seek(0, SeekOrigin.End);
        StreamWriter writer = new StreamWriter(tempStream);
        writer.WriteLine();
        writer.Flush();
        tempStream.Position = 0;

        StreamContent streamContent = new StreamContent(tempStream);
        foreach (var header in Request.Content.Headers)
        {
            streamContent.Headers.Add(header.Key, header.Value);

        }
        try
        {
            // Read the form data.
            streamContent.LoadIntoBufferAsync().Wait();

            //This is where it bugs out
            await streamContent.ReadAsMultipartAsync(provider);


            return Request.CreateResponse(HttpStatusCode.OK);
        }
        catch (Exception e)
        {
            return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e);
        }

}

I think the issue here is caused by:

headers: {
             "Content-Type": "multipart/form-data; boundary=gc0p4Jq0M2Yt08jU534c0p",
             "Content-Disposition": "form-data; name=Foo",
         }

I had a similar issue and was solved by removing the header parameters, am guessing that superagent adds them automatically.

Unexpected end of MIME multipart stream. MIME multipart message, with Web Api. I would like to upload a File in a WebApi Controller Methode, but I always get the Exception: "Unexpected end of MIME multipart stream. MIME MIME multipart message is not complete." I would appreciate  I'm using IntApp's Integration Builder to call the API, and I can use the tool to write the body of the request, but there's something off. I've used Fiddler to directly copy the request body from the OAuth sample, but I still get the same message "Unexpected end of MIME multipart stream."

I solved this problem by doing this:

 headers: {
                "Content-Disposition": "form-data; name=Foo",
                "enctype": "multipart/form-data"
          }

Error: Unexpected end of MIME multipart stream. MIME multipart , MIME multipart message is not complete. I'm getting this error when making the REST API call to add a new document. I'm using IntApp's  I'm trying to construct a single http request consisting of several sub-requests using mime/multipart requests. Here is my client code: def build_request( url, type, headers, data = {}): requ

I was able to solve this issue by removing the headers I set manually on my post method. Angular 6 + .NET Web Api

SuperAgent, Problem If you enabled Multi-Part Upload in your API request, sometimes you MIME multipart message is not complete. In SSIS REST API Task contains option AddMultiPartPostamble in property Grid (Added in v2.9.8). I have an Angular application, written in Typescript, with an ASP.Net Web Api backend. I am trying to use the ng-file-upload (see this link for details) directive to upload an image file. I receive an exception in my Web API Post method: "Unexpected end of MIME multipart stream. MIME multipart message is not complete."

Error 500, unexpected end of MIME multipart stream, on multipart , In web browsers absolute URLs work only if the server implements CORS. accepting the canonicalized MIME type name complete with type/subtype, or simply When parsing multipart responses, the object res.files is also available to you. BAD: this pipes garbage to the stream and fails in unexpected ways .​end((err,  Hello Everyone, I have a MVC5 Project with Web Api. I would like to upload a File in a WebApi Controller Methode, but I always get the Exception: "Unexpected end of MIME multipart stream.

javascript, Error 500, unexpected end of MIME multipart stream, on multipart POST #536. Closed MIME multipart message is not complete.". Googling it, I saw this page: https://stackoverflow.com/questions/13770536/asp-net-web-api-  Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Unexpected end of MIME multipart stream in web api, exceptionmessage":"unexpected end of mime multipart stream. mime stream. mime multipart message not complete. web api , superagent. I've been trying to get this working for hours it seems like something is wrong in my message format or something. All I'm trying to do is read a string but the developer I'm working with who is doing the iOS part only knows how to send multipart/form-data not content-type json. Here is exact error: Unexpected end of MIME multipart stream.

Comments
  • In my case, I was using Postman and removing the headers from the request, solved the issue.