Hello I was trying to uses Parse.com's Cloud Code API and I was trying to create a code snippet that will query the data that shows in my data browser
My cloud code is
Parse.Cloud.define("getDriver", function (request, response){
var User = Parse.Object.extend("User");
var query = new Parse.Query(User);
var lastlogin;
//response.success({"obj":request.params.objectId}); //works
query.equalTo("objectId",request.params.objectId);
query.find({
success: function(objs) {
response.success({"driver_id":objs.length});
},
error: function(error) {
// The object was not retrieved successfully.
// error is a Parse.Error with an error code and description.
}
});
});
I am calling the cloud code with php curl , the code is
$ch =curl_init("https://api.parse.com/1/functions/getDriver/");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,true);
curl_setopt($ch,CURLOPT_CAINFO,"ca-bundle.crt");
curl_setopt($ch,CURLOPT_HTTPHEADER,array('X-Parse-Application-Id: APPLICATION_ID','X-Parse-REST-API-Key: API_KEY', 'Content-Type: application/json'));
curl_setopt($ch,CURLOPT_POSTFIELDS, "{\"objectId\": \"NDpoVvFcGP\"}");
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
My problem is that the query always gives an empty result even though the correct objectId is being passed: NDpoVvFcGP
I cannot figure out this one. What might be the problem? Can someone please help?
Thanks