title: Getting error " The remote server returned an error: (400) Bad Request." on line WebResponse response = request.GetResponse();
body: <pre><code>//Create a request using a URL that can receive a post.
  WebRequest request = WebRequest.Create("https://go.urbanairship.com/api/push/");
  request.Credentials = new NetworkCredential("pvYMExk3QIO7p2YUs6BBkg", "rO3DsucETRadbbfxHkd6qw");
  
  // Set the Method property of the request to POST.
  request.Method = "POST";
  
  // Create POST data and convert it to a byte array.
  //WRITE JSON DATA TO VARIABLE D
  string postData = "{\"aps\": {\"badge\": 1, \"alert\": \"Hello from Urban Airship!\"}, \"device_tokens\": [\"6334c016fc643baa340eca25bc661d15055a07b475e9a6108f3f644b15dd05ac\"]}";
  byte[] byteArray = Encoding.UTF8.GetBytes(postData);
  
  // Set the ContentType property of the WebRequest.
  request.ContentType = "application/json";
  
  // Set the ContentLength property of the WebRequest.
  request.ContentLength = byteArray.Length;
  
  // Get the request stream.
  using (Stream dataStream = request.GetRequestStream())
  {
      // Write the data to the request stream.
      dataStream.Write(byteArray, 0, byteArray.Length);
  }
  
  // Get the response.
  WebResponse response = request.GetResponse();
  
  //Error "The remote server returned an error: (400) Bad Request"
  // Display the status.
  Console.WriteLine(((HttpWebResponse)response).StatusDescription);
  
  // Get the stream containing content returned by the server.
  using (Stream dataStream = response.GetResponseStream())
  {
      // Open the stream using a StreamReader for easy access.
      using (var reader = new StreamReader(dataStream))
      {
          // Read the content.
          string responseFromServer = reader.ReadToEnd();
  
          // Display the content.
          Console.WriteLine(responseFromServer);
  
          response.Close();
      }
  }
  </code></pre>