title: HTTPS request to a oAuth2 Keycloak server return me 400 'Bad Request' in Xamarin
body: <p>I'm translating a javascript code that works to a C# (Xamarin application). And I getback from the server 400  'Bad Request'</p>
  <p>I would like to know if the code I wrote in C# is correct or I missing something.</p>
  <p><strong>JS code:</strong></p>
  <pre><code>function requestTokens(code) {
      var codeVerifier = document.getElementById(&quot;codeVerifierValue&quot;).innerHTML;
      var data = {
          &quot;grant_type&quot;: &quot;authorization_code&quot;,
          &quot;client_id&quot;: &quot;clientid&quot;,
          &quot;code&quot;: code,
          &quot;code_verifier&quot;: codeVerifier,
          &quot;redirect_uri&quot;: &quot;https://redirectUrl&quot;
      };
      $.ajax({
          beforeSend: function (request) {
              request.setRequestHeader(&quot;Content-type&quot;, &quot;application/x-www-form-urlencoded; charset=UTF-8&quot;);
          },
          url: &quot;https://myUrl&quot;,
          data: data,
          success: responseFromPostRequest,
          dataType: &quot;json&quot;
      });
  }
  </code></pre>
  <p><strong>C# code:</strong></p>
  <pre><code>private HttpClient _httpClient = new HttpClient();
  
  private async Task&lt;string&gt; HttpPost(string url, DataDto data)
  {
      var jsonData = JsonConvert.SerializeObject(data);
      var content = new StringContent(jsonData, Encoding.UTF8, &quot;application/x-www-form-urlencoded&quot;);
  
      var response = await _httpClient.PostAsync(new Uri(url), content);
  }
  </code></pre>
  <p>Thanks for your help</p>
  <p><em><strong>Updated for log response:</strong></em></p>
  <pre><code>{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
  {
    Cache-Control: no-store
    Connection: keep-alive
    Date: Wed, 10 Nov 2021 17:37:43 GMT
    Pragma: no-cache
    Referrer-Policy: no-referrer
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Android-Received-Millis: 1636565866035
    X-Android-Response-Source: NETWORK 400
    X-Android-Selected-Protocol: http/1.1
    X-Android-Sent-Millis: 1636565857210
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 1; mode=block
    Content-Length: 84
    Content-Type: application/json
  }}
  </code></pre>