tmenier / Flurl

Fluent URL builder and testable HTTP client for .NET
https://flurl.dev
MIT License
4.23k stars 387 forks source link

PostMultipartAsync deformates request data #733

Closed Msey closed 1 year ago

Msey commented 1 year ago

I wanted to post a request with two strictly named files attached, but two same requests using flurl and rest sharp return different results to me :(

            // flurl doesn't work
            var result = await "https://operator.cprr-it.weintegrator.com/api/v0/poar-webapp/integration/poa"
                    .WithHeader("authorization", "Bearer " + Token)
                    .WithHeader("Content-Type", "multipart/form-data")
                    .PostMultipartAsync(mp => mp.AddFile("poa", fileA).AddFile("signature", fileB)); // status 500

            // rest sharp works
            var client = new RestClient("https://operator.cprr-it.weintegrator.com/api/v0/poar-webapp/integration/poa");
            var request = new RestRequest();

            request.Method = Method.Post;
            request.AddHeader("authorization", "Bearer " + Token);
            request.AddHeader("Content-Type", "multipart/form-data");
            request.AddFile("poa", fileA);
            request.AddFile("signature", fileB);
            var result2 = client.Execute(request); // status 200

I guess there's a problem with encodings or line endings

tmenier commented 1 year ago

I guess there's a problem with encodings or line endings

I don't know what you mean by that. Can you be more specific?

tmenier commented 1 year ago

I don't think you've identified a bug.

  1. I have no idea how to reproduce this.
  2. A 500 error returned from the server is like an unhandled exception. Flurl sent the request "successfully" but the server didn't know how to handle it. I have no idea why.
  3. I have no intimate knowledge of RestSharp's code and couldn't tell you why it "works" there.

In short, I have no idea what to do with this other than close it. Maybe try posting a question on Stack Overflow.