title: Getting Error=Missing Registration while sending HTTPPost to GCM Using Google Apps Script
body: <p>I am trying to send http post to GCM server using google apps script. I have the device ID and the proper credentials. Here is the code I am using:</p>
  
  <pre><code>function doThat(){
    var url = "https://android.googleapis.com/gcm/send";
    var options = {
      "method": "post",
      "headers": {
        "Authorization": "key=myAPIKEY",
        "Content-Type":"application/json"
      },
      "payload": {
        "data": {
          "score": "5x1",
          "time": "15:10"
        },
        "registration_ids": ["regid1"]
      }
    };
    var response = UrlFetchApp.fetch(url, options);
    Logger.log("Response: "+response.toString());
  }
  </code></pre>
  
  <p>Here, myAPIKEY and regid1 are place holders. 
  An equivalent java code works well for this. Hence there seems no problem with the credentials. 
  I went through <a href="https://developer.android.com/google/gcm/http.html" rel="nofollow">this</a> link of android documentation to find the format of json to be sent to GCM server as(Those who edit this code below note that the api keys and others are directly taken from that <a href="https://developer.android.com/google/gcm/http.html" rel="nofollow">link</a> on android GCM site. ITS NOT MINE.SO PLS DO NOT CHANGE IT):</p>
  
  <pre><code>    Content-Type:application/json
  Authorization:key=AIzaSyB-1uEai2WiUapxCs2Q0GZYzPu7Udno5aA
  
  {
    "registration_ids" : ["APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx..."],
    "data" : {
      ...
    },
  }
  </code></pre>
  
  <p>Note: If
  I always get "Error=Missing Registration" at Logger.log() statement in execution logs. The java equivalent code works perfect. But google script gives this error.So what is wrong here?</p>