Reputation: 5782
I'm getting empty response posts from google drive push notification api. I'm not sure if I'm not looking correctly at the posted data to my listening app or if I'm incorrectly setting up my channels.
I've able to setup channels verified with the responses like:
[14-07-26 14:27:19:697 EDT] {
"kind": "api#channel",
"id": "ce976221-7f6c-44bd-82f3-6a7a539fbc18",
"resourceId": "YTWyD_gD_mUUBM8Ttrqc6P6ZCxI",
"resourceUri": "https://www.googleapis.com/drive/v2/files/1T0GX4lBx6yH2DHMAS624qk5bQylZm1kRs_rE8tIHS_c?updateViewedDate=false&alt=json",
"token": "caller=https://script.google.com/a/macros/ccsknights.org/s/AKfycbxc0JwGl-TptxgsHhWPaAZbIgQXRk7fhB282ReOa09f_6HmGPkw/exec",
"expiration": "1406402836000"
}
And my listening app does receive notifications as I mess with the test document. I do a dump of the entire posted data but it shows up as:
{queryString=null, parameter={}, contextPath=, parameters={}, contentLength=0}
I've posted other data to the app to test it and it shows up as expected:
{queryString=bob/asdasd/asdasdsd/adsad, postData=FileUpload, parameter={test=yes, test2=no, bob/asdasd/asdasdsd/adsad=}, contextPath=, parameters={test=[Ljava.lang.Object;@2fc540bd, test2=[Ljava.lang.Object;@3f1d50cb, bob/asdasd/asdasdsd/adsad=[Ljava.lang.Object;@1da35fcc}, contentLength=17}
The listening app is simply:
var sslog = SpreadsheetApp.openById('1dOic6cWtTuj7lxi-QoRK2hrlXArd2C5ZlqOEmCvJ6R0').getSheets()[0];
function doPost(e) {
sslog.appendRow([e]);
return 200;
//return ContentService.createTextOutput().setContent(JSON.stringify(e)).setMimeType(ContentService.Mi meType.JSON);
}
Is there something I'm missing to be able to extract the push notification data from the post?
Upvotes: 1
Views: 341
Reputation: 5782
The correct answer is the post body is retrieved in the postData object. It was added but not documented. You can find more about it at: https://developers.google.com/apps-script/releases/2013
function doPost(e) {
Logger.log(e.postData.getDataAsString());
}
Upvotes: 1
Reputation: 2807
If you are watching a File resource, POST body is always empty. All of the information that's available to you is contained in "X-Goog-*" headers.
Upvotes: 1