I'm trying to upload files using the http client and I'm always getting a bad response from the backend. I'm assuming that the problem resides on the request, because apart from that, everything that my request has is exacly the same as the request I am making on aurelia http client.
In general here some information about the request headers from angular:
Request URL: https://*/document/document?name=ecv_template_en.pdf&classification=0
Request Method: POST
Content-Type: application/json
Request payload:
------WebKitFormBoundary1gYAP6XB8f1TQ7RP
Content-Disposition: form-data; name="blobFile"; filename="ecv_template_en.pdf"
Content-Type: application/pdf
------WebKitFormBoundary1gYAP6XB8f1TQ7RP--
And the same request from aurelia http client:
Request URL: https://*/document/document?name=ecv_template_en.pdf&classification=0
Request Method: POST
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarydb5u93415NsBfKEz
Now there isn't a request payload but a form data with a blobFile: (binary)
This is the angular code that I'm doing in order to reproduce the call:
const formData = new FormData();
formData.append("blobFile", documentUpload.file);
return this.http
.post(`${*}/document?name=${name}&classification=${classification}`,
formData).pipe(
map(do stuff))
);
I've also checked the content of the formData and it's exacly the same both on aurelia request and angular request.
Also the endpoint that I'm calling is the following:
[HttpPost()]
public ActionResult Create([FromForm]IFormFile blobFile,
[FromQuery] string name,
[FromQuery] ClassificationType classification)