title: json.Dumps - C# equivalent?
body: <p>I have the following API - documentation which seems to be written in Python:</p>
  
  <pre><code>request = {
  "username": "johndoe47",
  "password": "secret12345"
  }
  apiConnection.request("POST", "/api/session?sid=" + sid, json.dumps(request))
  response = json.loads(apiConnection.getresponse().read())
  </code></pre>
  
  <p>I need to access this REST-Service via C#</p>
  
  <p>I am a bit unsure, what "json.dumps" does. I tried the following:</p>
  
  <pre><code>data="{\"Username\":\"johndoe47\",\"password\":\"secret12345\"}";
  
      HttpWebRequest request=HttpWebRequest.Create("http://example.com/api/session?sid=workingsid");
              request.Method = "POST";
          request.ContentType = "text/plain;charset=utf-8";
  
          System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
          byte[] bytes = encoding.GetBytes(data);
  
          request.ContentLength = bytes.Length;
  
          using (Stream requestStream = request.GetRequestStream())
          {
              requestStream.Write(bytes, 0, bytes.Length);
          }
  
          request.BeginGetResponse((x) =&gt;
          {
              using (HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(x))
              {
                  StreamReader reader = new StreamReader(response.GetResponseStream());
                  retval = reader.ReadToEnd();
              }
          }, null);
  </code></pre>
  
  <p>I expect whatever json.dumps() does is not the same as I have done with "data=" as the server response is "missing username"</p>