Search code examples
javascriptnode.jsrestparse-cloud-codeparse-server

Parse Server Cloud Code Error 141: Unauthorized


I have just created a parse-server deployment for learning on Cloud9 and everything works fine when I am accessing it using the REST API using PostMan. I am now trying out Cloud Functions.

I have the following code in my cloud.js file,

Parse.Cloud.define('hello', function(request, response) {
    var query = new Parse.Query("Test");
      query.find({
          success: function(data){
              response.success(query);
          },
          error: function(err){
              response.error(err);
          }
      })
});

And in the response I get the following error,

{
  "code": 141,
  "error": {
    "message": "unauthorized"
  }
}

My request on PostMan looks something like this,

Postman request with headers and URL

The response is fine as long as I do not try a query and send a simple response like response.success("OK").

Is this an issue with Parse or am I missing something related to authorization?


Solution

  • All I had to do was add useMasterKey: true in the find method.

    query.find({ useMasterKey: true, success: function(data){ response.success(query); }, error: function(err){ response.error(err); } })