title: How do I send API credentials and username / password with .Net / Parse.com? (PHP to C#)
body: <p>I am trying to create a web page that will allow my users to login and view their data. The data is hosted on Parse.com which exposes it as a REST API.</p>
  
  <p>I am using asp.net / C# to access it and can get it all by using their API Key and Application Key. However, I need to write a version of this PHP code from their documentation in C#...</p>
  
  <blockquote>
    <p>To do this, send a GET request to the /1/login endpoint with username and password as URL-encoded parameters:</p>
  </blockquote>
  
  <pre><code>curl -X GET \
  -H "X-Parse-Application-Id: ${APPLICATION_ID}" \
  -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
  -G \
  --data-urlencode 'username=cooldude6' \
  --data-urlencode 'password=p_n7!-e8' \
  https://api.parse.com/1/login
  </code></pre>
  
  <p>Now I am stuck here...anything that I have tried returns an HTTP 400, such as this code...</p>
  
  <pre><code>[WebMethod]
  [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  public static string ParseAuthenticate(string strUserName, string strPassword )
  {
      var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.parse.com/1/login");
      httpWebRequest.ContentType = "application/x-www-form-urlencoded";
  
      httpWebRequest.Headers.Add("username:" + strUserName);
      httpWebRequest.Headers.Add("password:" + strPassword);
  
      //pass basic authentication credentials
      httpWebRequest.Credentials = new NetworkCredential("My Parse Application Id", "Parse API Rest Key");
  
      httpWebRequest.Method = "GET";
  
      var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
  
      using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
      {
          var responseText = streamReader.ReadToEnd();
          return responseText;
      }
  
  }
  </code></pre>
  
  <p>Here is my C# code that gets me all the data...but I only want data for the user that is trying to login...</p>
  
  <pre><code>[WebMethod]
  [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  public static string GetParseData()
  {
      var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.parse.com/1/classes/Visit");
  
      //pass basic authentication credentials
      httpWebRequest.Credentials = new NetworkCredential("My Parse Application Id", "My Parse REST API Key");
      httpWebRequest.Method = "GET";
  
      var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
  
      using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
      {
          var responseText = streamReader.ReadToEnd();
          return responseText;
      }
  
  }
  </code></pre>
  
  <p>Any help / pointers will be greatly appreciated. Thanks!</p>