Hi Everyone,
I am currently working for a non profit organization on an integration between my parse server (hosted on AWS) and a Google spreadsheet. I am trying to POST new rows in classes using the google script of the google spreadsheet.
So far I succeded to:
- make GET request to from parse and collect the results.
- makePOST request to parse and add new items in a parse class as long as I don’t specify any date or any pointer.
The following POST resquest is working fine:
//Define the API KEY and APP ID
var API_KEY = 'blablabla';
var applicationId ='blablabla'
function InsertIntoParse() {
//Define URL
var root = 'http://blablbla.amazonaws.com:80/parse';
var endpoint = '/classes/JEPT_ENFANT';
//Define parameters
var params = {
"method": "POST",
"muteHttpExceptions": true,
"Content-Type": "application/json",
"headers": {
"X-Parse-Application-Id": applicationId,
"X-Parse-REST-API-Key": API_KEY
},
"payload":{
"enf_prenom": "John",
"enf_sexe": "Homme"
}
};
//Send Request
var response = UrlFetchApp.fetch(root+endpoint, params);
Logger.log('SK PARSE='+response);
}
If I add the pointer on the fam_cd column:
"payload":{
"enf_prenom": "John",
"enf_sexe": "Homme",
"fam_cd":{"__type":"Pointer","className":"JETP_FAMILLE","objectId":"n4qkgYC0Qg"}
}
The script won’t work and return the following message:
{"code":111,"error":"schema mismatch for JEPT_ENFANT.fam_cd; expected Pointer<JETP_FAMILLE> but got String"}
Please note that the same payload used on the parse dashboard API Console work fine.
I have also tried the following possibilities:
"fam_cd":"n4qkgYC0Qg"
"fam_cd": {"__op":"AddRelation","objects":[{"__type":"Pointer","className":"JETP_FAMILLE","objectId":"n4qkgYC0Qg"}]}
I have a similar issue with the Date columns. The follwing payload :
"payload":{
"enf_prenom": "John",
"enf_sexe": "Homme",
"enf_ddn": {"__type": "Date", "iso": "2018-04-18T01:00:00.000Z"}
}
Returns the follwing error message:
{"code":111,"error":"schema mismatch for JEPT_ENFANT.enf_ddn; expected Date but got String"}
I have also tried the following possibilities :
"enf_ddn": {"__type": "Date", "iso": "2018-04-18T01:00:00.000"}
"enf_ddn": {"__type": "Date", "iso": "2018-04-18T01:00:00Z"}
"enf_ddn": {"__type": "Date", "iso": "2018-04-18'T'01:00:00.000'Z'"}
"enf_ddn": {"__type": "Date", "iso": "2018-04-18"}
"enf_ddn": "2018-04-18"
"enf_ddn": {"__type": "Date", "iso": new Date(2018,04,18)}
var DateBirth = Utilities.formatDate(new Date(2018,03,18), "GMT+1", "yyyy-MM-dd'T'HH:mm:ss'Z'")
"enf_ddn": {"__type": "Date", "iso": DateBirth}
Clearly there is an issue in the way I send the information to the REST API but I can’t understand why it works with Strings and with the API Console of the Dashboard and it’s not working for Pointers and Dates!
I’m open and thankful for any idea you will suggest. Please note that I’m not that skilled in the use of APIs and in hte use of Parse platform.
Thanks a lot!
Slim