I'm trying to upload a file from a Angular client to my ASP.NET Core 2 WebAPI service. When I call the service, I get back an Internal Server Error. That's the error I'm getting:
The component I'm using client-side is this one: ngx-uploader
In my request options, i set them as you can see here:
const event: UploadInput = {
type: 'uploadAll',
url: this.printService.apiFilesBaseUrl + '/Upload',
method: 'POST',
file: this.files[0],
headers: {
'Content-Type': 'multipart/form-data',
'Accept': '*/*',
'Authorization': 'Bearer ' + this.authService.getToken()
}
};
While, server-side my controller action signature is this one:
[HttpPost]
[Route("Upload")]
[Authorize]
public Guid Post(IFormFile file)
Breakpoints in this controller action never get hit.
Can someone please share ideas about what's happening here?
Here, as requested, i will post my request header and payload:
Thanks in advance.
Check upload request in developer tools network tab, it should have correct format (matching 'Content-Type': 'multipart/form-data'
), also you could try removing this header.
You can add content-type: as multipart/form-data; boundary=--14737809831466499882746641449.
I am testing API on postman and added content-type like above it worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With