Google Apps Script UrlFetchApp with JSON Payload -
i'm trying post web service expecting json payload using google apps script. i'm using following code:
var options = { "method" : "post", "contenttype" : "application/json", "headers" : { "authorization" : "basic <base64 of user:password>" }, "payload" : { "enddate": "2012-06-03" } }; var response = urlfetchapp.fetch("http://www.example.com/service/expecting/json", options); on server side i'm getting following error:
warn [facade.settingsservlet] 04 jun 2012 15:30:26 - unable parse request body: enddate=2012-06-03 net.liftweb.json.jsonparser$parseexception: unknown token e i'm assuming server expecting
{ "enddate": "2012-06-03" } instead of
enddate=2012-06-03 but don't know how make urlfetchapp it.
i not understand server side error 'payload' parameter must string specified here: https://developers.google.com/apps-script/class_urlfetchapp?hl=fr-fr#fetch.
try:
var options = { "method" : "post", "contenttype" : "application/json", "headers" : { "authorization" : "basic <base64 of user:password>" }, "payload" : '{ "enddate": "2012-06-03" }' };
Comments
Post a Comment