My Parse-server-example repo on GitHub was deployed to Heroku (NOT via the Heroku button) via deployment of my GitHub repo.
I used a cURL POST command line trying to add a new record in the GCUR_OBSERVATION class on my MongoLab hosted database,
curl -X POST -H "X-Parse-Application-Id: MY_APP_ID" -H "X-Parse-Master-Key: MY_MASTER_KEY" -H "Content-Type: application/json" -d "{\"ObservationStatus\":0}" https://{MY_APP}.herokuapp.com/parse/classes/GCUR_OBSERVATION
A beforeSave Cloud function was defined in the Cloud code file "main.js" for the GCUR_OBSERVATION class as below:
Parse.Cloud.beforeSave("GCUR_OBSERVATION", function(request, response) {
console.log("*** beforeSave on GCUR_OBSERVATION called");
Parse.Cloud.useMasterKey();
sharedWithJurisArr = [];
console.log("*** FLAG 1");
if(!request.object.existed()) {
console.log("*** FLAG 2");
var sharedJurisSettingsQ = new Parse.Query("GCUR_SHARED_JURIS_SETTINGS");
console.log("*** FLAG 21");
sharedJurisSettingsQ.find().then(function(sjsObjs) {
console.log("*** FLAG 22");
for (var i = 0; i < sjsObjs.length; i ++) {
var jurisdiction = sjsObjs[i].get("Jurisdiction");
console.log("*** jurisdiction:" + jurisdiction);
sharedWithJurisArr.push(jurisdiction);
}
console.log("*** FLAG 23");
var sharedByArr = [];
console.log("*** FLAG 24");
for (var i = 0; i < sharedWithJurisArr.length; i ++) {
sharedByArr.push({
"st" : sharedWithJurisArr[i],
"sh" : true
});
}
console.log("*** FLAG 25");
request.object.set("SharedBy", JSON.stringify(sharedByArr));
console.log("*** FLAG 3");
response.success();
});
} else {
console.log("*** FLAG 4");
response.success();
}
});
Heroku logs showed the following messages after the cURL POST request was made:
2016-02-25T11:50:54.199259+00:00 app[web.1]: *** beforeSave on GCUR_OBSERVATION called
2016-02-25T11:50:54.199268+00:00 app[web.1]: *** FLAG 1
2016-02-25T11:50:54.199293+00:00 app[web.1]: *** FLAG 2
2016-02-25T11:50:54.199326+00:00 app[web.1]: *** FLAG 21
2016-02-25T11:51:24.195056+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/parse/classes/GCUR_OBSERVATION" host=nemp-qld-test.herokuapp.com request_id=d517a443-f264-4adb-83db-f2c077c9da71 fwd="183.78.173.3" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0service=30001ms status=503 bytes=0
I have tried the similar cURL POST command line to add a new record to any other class that does *_not *_have a beforeSave cloud function defined. But that worked.
So I am guessing it was the beforeSave function that caused the error.
My Parse-server-example repo on GitHub was deployed to Heroku (NOT via the Heroku button) via deployment of my GitHub repo.
I used a cURL POST command line trying to add a new record in the GCUR_OBSERVATION class on my MongoLab hosted database,
curl -X POST -H "X-Parse-Application-Id: MY_APP_ID" -H "X-Parse-Master-Key: MY_MASTER_KEY" -H "Content-Type: application/json" -d "{\"ObservationStatus\":0}" https://{MY_APP}.herokuapp.com/parse/classes/GCUR_OBSERVATIONA beforeSave Cloud function was defined in the Cloud code file "main.js" for the GCUR_OBSERVATION class as below:
Heroku logs showed the following messages after the cURL POST request was made:
I have tried the similar cURL POST command line to add a new record to any other class that does *_not *_have a beforeSave cloud function defined. But that worked.
So I am guessing it was the beforeSave function that caused the error.