415 Unsupported Media Type asp.net core
26,390
Solution 1
Try using [FromForm]
instead of [FromBody]
for the method parameter if you're POSTing form data.
Solution 2
In Postman, when creating a POST request, the default is "Text". Change it to JSON.
Solution 3
In Postman, after ensuring that you're using raw and its in JSON format. Most especially when making GET request and you're not sending any data in the body of the request ensure that the body of the request is not empty. It must have an empty object: { }
Author by
Malik Kashmiri
Updated on August 06, 2020Comments
-
Malik Kashmiri almost 4 years
Detail
I am trying to post a file from Postman to the endpoint I have created. but it gives me this error. I am not passing the header Content-Type in postman
415 Unsupported Media Type
API
[Consumes("multipart/form-data")] [HttpPost] public async Task<IActionResult> SendEmail([FromBody]Entity entity) { try { return OK(); } catch (Exception e) { throw e; } }
Class
public class Entity { public List<IFormFile> Files { get; set; } }