title: Accept x-www-form-urlencoded in Web API .NET Core
body: <p>I have a .NET Core Web API that is returning a 415 Unsupported Media Error when I try to post some data to it that includes some json.  Here's part of what is returned in the Chrome Debugger:</p>
  <pre><code>Request URL:http://localhost:51608/api/trackAllInOne/set
  Request Method:POST
  Status Code:415 Unsupported Media Type
  Accept:text/javascript, text/html, application/xml, text/xml, */*
  Content-Type:application/x-www-form-urlencoded
  
  action:finish
  currentSco:CSharp-SSLA:__How_It_Works_SCO
  data:{&quot;status&quot;:&quot;incomplete&quot;,&quot;score&quot;:&quot;&quot;}
  activityId:13
  studentId:1
  timestamp:1519864867900
  </code></pre>
  <p>I think this has to do with my controller not accepting <code>application/x-www-form-urlencoded</code> data - but I'm not sure.  I've tried decorating my controler with <code>Consumes</code> but that does not seem to work.</p>
  <pre class="lang-cs prettyprint-override"><code>[HttpPost]
  [Route(&quot;api/trackAllInOne/set&quot;)]
  [Consumes(&quot;application/x-www-form-urlencoded&quot;)]
  public IActionResult Post([FromBody] PlayerPackage playerPackage)
  { etc..}
  </code></pre>
  <p>Any help greatly appreciated.</p>
  <p>The following code worked fine in .NET 4.6.1 and I am able to capture and process the posts shown above.</p>
  <pre class="lang-cs prettyprint-override"><code>[ResponseType(typeof(PlayerPackage))]
  public async Task&lt;IHttpActionResult&gt; PostLearningRecord(PlayerPackage playerPackage)
  {
      if (!ModelState.IsValid)
      {
          return BadRequest(ModelState);
      }
  
      var id = Convert.ToInt32(playerPackage.ActivityId);
      var learningRecord = await _context.LearningRecords.FindAsync(id);
      if (learningRecord == null)
          return NotFound();
  etc...
  </code></pre>