title: Sending notification to GCM using HTTP POST
body: <p>I'm trying to send an <code>HTTP POST</code> notification to Google Cloud Messaging in order for a notification to be delivered to the app that I am developing.</p>
  
  <p>For testing purposes, I am also delivering the <code>HTTP POST</code> from the app as well - just to see if I can get a response (will implement this logic server-side later).</p>
  
  <p>I am following the tutorial found <a href="http://developer.android.com/google/gcm/http.html" rel="nofollow">here</a> but it's hard to follow as I am not using <code>JSON</code>. When I run the code below, I get the expected response: <code>Unauthorized: Error 401</code>. This is because I am not supplying enough data, but cannot seem to discover which data I need to send with this request. </p>
  
  <pre><code>class RequestTask extends AsyncTask&lt;String, String, String&gt;
      {
          final static String API_KEY = ***********; // From google developer console
          final static String CONTENT_TYPE = "application/x-www-form-urlencoded;charset=UTF-8";
          @Override
          protected String doInBackground(String... uri)
          {
              String responseString = "";
              HttpClient client = new DefaultHttpClient();
              HttpPost post = new HttpPost(uri[0]);
              try
              {
                  List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(1);
                  // not even sure if "Authorization" is the correct key to send
                  nameValuePairs.add(new BasicNameValuePair("Authorization", "key=" + API_KEY));
                  nameValuePairs.add(new BasicNameValuePair("Content-Type", CONTENT_TYPE));
                  HttpEntity entity = new UrlEncodedFormEntity(nameValuePairs);
                  post.addHeader(entity.getContentType());
                  post.setEntity(entity);
  
                  HttpResponse response = client.execute(post);
                  BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                  String line = "";
                  while ((line = rd.readLine()) != null)
                  {
                      Log.i("HTTP RESPONSE", line);
                      responseString = responseString + "\n" + line;
                  }
              }
              catch (Exception ex)
              {
                  ex.printStackTrace();
              }
  
              return responseString;
          }
  
          @Override
          protected void onPostExecute(String result)
          {
              super.onPostExecute(result);
              Intent intent = new Intent(ctx, ResponseActivity.class);
              intent.putExtra("text", result);
              startActivity(intent);
          }
      }
  </code></pre>
  
  <p>What must I change in order to successfully send this GCM notification request?</p>