title: HTTP POST Returns 400 Bad Request
body: <p>Python code with same headers and payload works fine</p>
  <p>Here non-working example in .NET vs working one with Python
  headers.cs</p>
  <pre class="lang-cs prettyprint-override"><code>        public string Postheaders(string url, string data, string deviceID, string deviceID_sig, string userAgent)
          {
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
              request.Method = &quot;POST&quot;;
              request.Headers[&quot;NDCDEVICEID&quot;] = deviceID;
              request.Headers[&quot;NDC-MSG-SIG&quot;] = deviceID_sig;
              request.Headers[&quot;Accept-Language&quot;] = &quot;en-US&quot;;
              request.UserAgent = userAgent;
              request.Host = host;
              request.ContentType = &quot;application/json; charset=utf-8&quot;;
              request.ContentLength = data.Length;
              var requestStream = request.GetRequestStream();
              using (var streamWriter = new StreamWriter(requestStream))
              {
                  streamWriter.Write(data);
              }
              var webResponse = (HttpWebResponse)request.GetResponse();
              var webStream = webResponse.GetResponseStream();
              var responseReader = new StreamReader(webStream);
              var response = responseReader.ReadToEnd();
              return response;
          }
  </code></pre>
  <p>client.cs</p>
  <pre class="lang-cs prettyprint-override"><code>        public string Login(string email, string password)
          {
              var deviceinfo = new device();
              var headers = new headers();
              string data = new JavaScriptSerializer().Serialize(new
              {
                  email = email,
                  v = 2,
                  secret = string.Format(&quot;0 {0}&quot;, password),
                  deviceID = deviceinfo.deviceID,
                  clientType = 100,
                  action = &quot;normal&quot;,
                  timestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds*1000
          });
              string response = headers.Postheaders(string.Format(&quot;{0}/g/s/auth/login&quot;, api), data, deviceinfo.deviceID, deviceinfo.deviceID_sig, deviceinfo.userAgent);
              return response;
          }
  </code></pre>
  <p>(pls don't judge me for bad coding if I have any, I'm still dumb)</p>
  <p>headers.py:</p>
  <pre class="lang-py prettyprint-override"><code>class Headers:
      def __init__(self, device = device.DeviceGenerator(), data = None, type = None):
          headers = {
              &quot;NDCDEVICEID&quot;: device.device_id,
              &quot;NDC-MSG-SIG&quot;: device.device_id_sig,
              &quot;Accept-Language&quot;: &quot;en-US&quot;,
              &quot;Content-Type&quot;: &quot;application/json; charset=utf-8&quot;,
              &quot;User-Agent&quot;: device.user_agent,
              &quot;Host&quot;: &quot;service.narvii.com&quot;,
              &quot;Accept-Encoding&quot;: &quot;gzip&quot;,
              &quot;Connection&quot;: &quot;Keep-Alive&quot;
          }
  
          if data: headers[&quot;Content-Length&quot;] = str(len(data))
          if sid: headers[&quot;NDCAUTH&quot;] = f&quot;sid={sid}&quot;
          if type: headers[&quot;Content-Type&quot;] = type
          self.headers = headers
  </code></pre>
  <p>client.py</p>
  <pre class="lang-py prettyprint-override"><code>    def login(self, email: str, password: str):
          data = json.dumps({
              &quot;email&quot;: email,
              &quot;v&quot;: 2,
              &quot;secret&quot;: f&quot;0 {password}&quot;,
              &quot;deviceID&quot;: self.device_id,
              &quot;clientType&quot;: 100,
              &quot;action&quot;: &quot;normal&quot;,
              &quot;timestamp&quot;: int(timestamp() * 1000)
          })
  
          response = requests.post(f&quot;{self.api}/g/s/auth/login&quot;, headers=headers.Headers(data=data).headers, data=data)
  </code></pre>
  <p>Everything works fine until
  <code>var webResponse = (HttpWebResponse)request.GetResponse();</code>, where it just returns &quot;400 Bad Request&quot;.</p>