Postman file and json returns 415 even with Content-Type Header .net core

Viewed 4010

I am using postman to test my .net core API, when i am trying to post data via postman form-data this returns a 415 even if i set the Content-Type header to application/json as the common solution for this issue appears to be online. If i fire the request without any files via the raw postman option and set the content type as JSON(application/json) this request reaches the API successfully.

Here is how my API looks:

 [HttpPost("{organization}")]
    public IActionResult Post([FromBody] Asset asset, string organization)
    {
       //Api body
       //Get files from request
       Task uploadBlob = BlobFunctions.UploadBlobAsync(_blobContainer,Request.Form.Files[0]);
    }

And here is how the failed postman request looks like enter image description here

and the header for that request

enter image description here

What else am i missing for this to work?

Small update

This works fine if i remove [FromBody]Asset asset and just pass the file

2 Answers
Related