I created Web API endpoint to receive a zip file which looks like this
[HttpPut()]
[Consumes("application/zip")]
public async Task<IActionResult> ImportZip()
{
var zipFile = HttpContext.Request.Form.Files.FirstOrDefault();
....
And I'm trying to test it via Postman with such request:
But I'm getting exception "System.InvalidOperationException: Incorrect Content-Type: application/zip"
What I'm doing wrong? Thanks!
EDIT Request actually passes through [Consumes("application/zip")] attribute, but crashing on "HttpContext.Request.Form.Files.FirstOrDefault();"
EDIT2
Ok, so finally I successfully received a file when I didn't put any header in the request and removed [Consumes("application/zip")] attribute. In Request.Form.Files
my file have a type "application/x-zip-compressed" but when I'm trying to use it in headers content-type and in Consumes attribute I get same crash System.InvalidOperationException: Incorrect Content-Type: application/x-zip-compressed