title: How to accept a bodyless GET request with JSON as it's content type?
body: <p>After migrating to ASP.NET Core 2.1 we have realized that some consumers of our API are sending GET requests with the <code>Content-Type</code> header set to <code>application/json</code>. Sadly, these requests have not been rejected in the past (even though they should have), nevertheless this still is a breaking change..</p>
  
  <p>Since our consumers need to fix this issue on their end, and this will take some time, we would like to temporarily accept these requests so we're not stuck waiting for this.</p>
  
  <p>The framework (correctly) rejects the request with the following error message: <code>"A non-empty request body is required."</code></p>
  
  <p>The action looks like this:</p>
  
  <pre><code>[Route("api/file/{id:guid}")]
  public async Task&lt;IActionResult&gt; Get(Guid id)
  {
       // Some simple code here
  }
  </code></pre>
  
  <p>The code inside the action isn't being reached as the error is already been thrown before it reaches the action (due to the incorrect request).</p>
  
  <p>@Nkosi's solution resulted in the same response:</p>
  
  <pre><code>[HttpGet("api/file/{id:guid}")]
  public async Task&lt;IActionResult&gt; Get([FromRoute]Guid id)
  {
       // Some simple code here
  }
  </code></pre>
  
  <p>The (PHP) cURL that the consumer uses is this:</p>
  
  <pre><code>$ch = curl_init(self::API_URL."/file/".$id);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      "Content-Type: application/json",
      "Application: APPKey ".$this-&gt;AppKey,
      "Authorization: APIKey ".$this-&gt;ApiKey
  ));
  </code></pre>
  
  <p>Removing the <code>"Content-Type: application/json",</code> line turns the request into a valid requests, so we're 99.9% sure that the addition of this header is the evildoer.</p>