title: JSON C# WebRequest returns error 400 bad request
body: <p>Following code throws an error on request.GetResponse(). It returns an error 400 bad request. I tried different things but so far without any succes. Is there anything I can do to get more detail about the error 400?</p>
  
  <pre><code>string sURL = "https://testservice.mywebsite.be/games/1/players";
          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sURL);
          request.Method = "POST";
          request.Accept = "application/json";
          request.ContentType = "application/json";
  
          String sTimestamp = DateTime.Now.ToUniversalTime().ToString("yyyyMMddHHmmss");
          string sHMACmessage = string.Format("verb={0}&amp;timestamp={1}&amp;url={2}&amp;playernumber={3}", request.Method.ToString().ToUpperInvariant(), sTimestamp, sURL, sPlayerNumber);
          byte[] bHash = HashHMAC(StringEncode("myprivatekey"), StringEncode(sHMACmessage));
          string sHash = HashEncode(bHash);
  
          request.Headers.Add("Timestamp", sTimestamp);
          request.Headers.Add("PlayerNumber", sPlayerNumber);
          request.Headers.Add("Authentication", String.Concat("mypublickey", ":", sHash));
  
          using (var streamWriter = new StreamWriter(request.GetRequestStream()))
          {
              string json = "{\"playingYear\":\"2015\"}";
              streamWriter.Write(json);
          } 
          long length = 0;
          try
          {
              using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
              {
                  length = response.ContentLength;
              }
          }
          catch (WebException ex)
          {
              throw;
          }
  </code></pre>