title: 415 (Unsupported Media Type) Error
body: <p>On my MVC project, I have a POST request to a Web API using <code>XmlHttpRequest</code>.</p>
  
  <p>I send an array of documents' routes in a JSON format and expecting to get from the server a Zip file (ArrayBuffer). </p>
  
  <pre><code>self.zipDocs = function (docs, callback) {
      var xhr = new XMLHttpRequest();
  
      xhr.onreadystatechange = function () {//Call a function when the state changes.
          if (xhr.readyState == 4 &amp;&amp; xhr.status == 200) {
              alert(xhr.responseBody);
          }
      }
      xhr.open("POST", '../API/documents/zip', true);
      xhr.setRequestHeader("Content-type", "application/json");
      xhr.responseType = "arraybuffer";
      console.log(docs);
      xhr.send(docs);
  
      var arraybuffer = xhr.response;
      var blob = new Blob([arraybuffer], { type: "application/zip" });
      saveAs(blob, "example.zip");
  }
  </code></pre>
  
  <p>And my ZipDocs function on the WebAPI (using the DotNetZip library):</p>
  
  <pre><code>[HttpPost]
      [Route("documents/zip")]
      public HttpResponseMessage ZipDocs([FromBody] string[] docs)
      {
  
      using (var zipFile = new ZipFile())
      {
          zipFile.AddFiles(docs, false, "");
          return ZipContentResult(zipFile);
      }
  }
  
  protected HttpResponseMessage ZipContentResult(ZipFile zipFile)
  {
      // inspired from http://stackoverflow.com/a/16171977/92756
      var pushStreamContent = new PushStreamContent((stream, content, context) =&gt;
      {
         zipFile.Save(stream);
          stream.Close(); // After save we close the stream to signal that we are done writing.
      }, "application/zip");
  
      return new HttpResponseMessage(HttpStatusCode.OK) { Content = pushStreamContent };
  }
  </code></pre>
  
  <p>But the response I'm getting from the server is:</p>
  
  <blockquote>
  <pre><code>POST http://localhost:1234/MyProject/API/documents/zip 415 (Unsupported Media Type)
  </code></pre>
  </blockquote>
  
  <p>Why is this happening, and how do I fix it?</p>