Google Script CURL post to back4App

1,182 views
Skip to first unread message

daew...@gmail.com

unread,
Jun 25, 2018, 4:52:57 PM6/25/18
to Back4App
Hei, I'm trying to post via rest api from google script.

Spend all day, but still can't manage it.

Getting return code 400, truncated server. Anyone knows how to make it work? thanks in advance:

My Code:

function myFunction() {
  var payload = JSON.stringify({
    "score": 1337,
    "playerName": 'Sean Plott',
    "cheatMode": false
});
 
   var headers = {
        "X-Parse-Application-Id": 'myid',
        "X-Parse-Master-Key": 'mykey',
        "X-Parse-Url": 'https://parseapi.back4app.com/',
    };
 
var options = {
    'method': 'post',
    'payload': payload,
    'Content-Type': 'application/json',
    //muteHttpExceptions : true,
    'headers': headers
};
var test = UrlFetchApp.fetch('https://parseapi.back4app.com/classes/GameScore', options);
Logger.log(test);

}

daew...@gmail.com

unread,
Jun 26, 2018, 11:24:24 AM6/26/18
to Back4App

Looks like the problem was header "Content-Type". Changed to "contentType" and it worked perfectly.

cha...@back4app.com

unread,
Jun 26, 2018, 5:34:05 PM6/26/18
to Back4App
Hi!

Thanks for share the solution, we really appreciate that.

Feel free to reach us whenever you need! (:

Regards,
Charles Ramos
Reply all
Reply to author
Forward
0 new messages