title: Getting InvalidOperationException: Incorrect Content-Type: text/plain exception when processing file through Web API Core
body: <p>I am having an API.Net Core Web API app that has a POST method that accepts and processes a PDF file.</p>
  
  <p>However, when I try to test in POSTMAN (Selecting POST, selecting Binary, choosing a file) I get a following error</p>
  
  <blockquote>
    <p>InvalidOperationException: Incorrect Content-Type: text/plain</p>
  </blockquote>
  
  <p>At the following line</p>
  
  <blockquote>
    <p>var file = Request.Form.Files[0];</p>
  </blockquote>
  
  <p>Please let me know if there is anything I need to fix</p>
  
  <p>Thank you in advance</p>
  
  <p>Here is the entire method</p>
  
  <pre><code>[HttpPost]
  [Route("SubmitForm")]
  public async Task&lt;IActionResult&gt; SubmitForm()
  {
  
      var file = Request.Form.Files[0];
      HttpClient client = GetClient();
      try
      {
  
          byte[] docAsBytes;
          using (var ms = new MemoryStream())
          {
              file.CopyTo(ms);
              docAsBytes = ms.ToArray();
              string s = Convert.ToBase64String(docAsBytes);
              // act on the Base64 data
          }
  
          PdfReader pdfReader = new PdfReader(docAsBytes);
          MemoryStream m = new MemoryStream();
          PdfStamper outStamper = new PdfStamper(pdfReader, m);
          string formName = outStamper.AcroFields.GetField("FormSeqNo");
  
          string endpointUrl = "https://myproject.sharepoint.com/sites/project" + String.Format(
             "/_api/web/GetFolderByServerRelativeUrl('{0}')/Files/Add(url='{1}', overwrite=true)",
             this.Config["TemplateLibrary"].Replace(" ", "%20"),
             formName + ".pdf");
  
          ByteArrayContent imageBytes = new ByteArrayContent(docAsBytes);
          var result = await client.PostAsync(endpointUrl, imageBytes);
  
          //return result.Content.ToString();
      }
      catch (Exception ex)
      {
          //return ex.ToString();
      }
  
      return Ok(); 
  }
  </code></pre>