Description
I have defined a Cloud function in main.js as below:
Parse.Cloud.define('getAllCurrentObs', function(request, response) {
Parse.Cloud.useMasterKey();
var queryObs = new Parse.Query("GCUR_OBSERVATION");
queryObs.ascending("createdAt");
queryObs.equalTo("ObservationStatus", 0);
queryObs.limit(1000);
queryObs.find().then(function(results) {
response.success(results.length);
}, function(error) {
response.error("Error: " + error.code + " " + error.message);
});
});
While trying the POST cURL command line to call the function, the command line prompt showed the following error message:
curl -X POST -H "X-Parse-Application-Id: APP_ID" -H "X-Parse-Master-Key: MASTER_KEY" -H "Content-Type: application/json" -d "{}" https://{MY_APP_NAME}.herokuapp.com/parse/functions/getAllCurrentObs
{"code":141,"error":"Error: 100 XMLHttpRequest failed: \"Unable to connect to the Parse API\""}
The Heroku logs page showed:
2016-02-25T12:33:14.263956+00:00 heroku[router]: at=info method=POST path="/parse/functions/getAllCurrentObs" host={MY_APP_NAME}.herokuapp.com request_id=6af8cfa4-c935-4b52-a869-1d5dd47b93aa fwd="183.78.173.3" dyno=web.1 connect=0ms service=2764ms status=400 bytes=378
By the way, using cURL to post the default "hello" cloud function worked well.
Edit: I think the problem is any Parse Query made to a DB Class in a cloud function would fail.