5

I'm trying to successfully get data from a MongoDB Parse database using cloud code implemented in Swift. I am receiving an error code: [Error]: { code = 107; message = "Received an error with invalid JSON from Parse: Cannot POST /parse/classes/Event"; } (Code: 141, Version: 1.13.0)

Here is my server code:

Parse.Cloud.define('function1', function(request, response) {  
    Parse.Cloud.useMasterKey();

    var event = Parse.Object.extend("Event");
    var query = new Parse.Query(event);
    query.first({
      success: function(object) {
     reponse.success("hey");
    },
    error: function(error) {
      response.error(error);
    }
    });
});

Here is my Swift code:

    PFCloud.callFunctionInBackground("function1", withParameters: []) { (result:AnyObject?, error:NSError?) in
        print("result: ")
        print(result)
        if ((error) != nil) {
            print(error?.localizedDescription)
        }
    }

Also result is printing as nil.

Thomas
  • 147
  • 1
  • 2
  • 8
  • Did you ever figure it out? – mdimarca Sep 26 '17 at 00:41
  • There are still a number of things that can go wrong here. Since I have not done a lot of Mongo and nor Parse so far a lot of this will be guesswork, but since you did not provide it ... First of all why do you respond with `"hey"` in your `success` case? Should that not be `object`? Or should you not at least log `object` on the server in the `success` case in order to be able to tell us how it looks? On the other hand you should try hard to figure out a way to show us the "raw" response string from your call. Are you sure you actually get through to the server by the way? More info please. – Patru May 22 '18 at 20:39

0 Answers0