I have a dotnet API server and I want to send images in the request body, but when I make a request from postman I have an error "Unsupported Media Type"
here is my API controller, I have changed the argument of the function from an object to a byte array but it does not help, what should I do to be able to send a request with a file in the body as binary to handle it
you can get file with IFormFile
.
E.g:
[HttpPost]
public ActionResult PostImage([FromForm] IFormFile image){
if (image == null || image.Length == 0)
{
return BadRequest();
}
// Do something with image
}
Now I do not have an error about content type but the image is null
@AkezhanOb1 in postman your request's body needs to be form-data.
Yeah I know, I have already changed but still, the image is null
Parameter name (image) in controller and key at form-data needs to be same.