parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

JSON text did not start with array or object and option to allow fragments not set.

Open jaydeep82 opened this issue 10 years ago • 32 comments

Hello Friends,

I've migrated the parse-server code on my aws ec2 server. Before testing to my code, I've tried to connect to parse server as mentioned below.

Parse.initializeWithConfiguration(ParseClientConfiguration(block: { ( configuration : ParseMutableClientConfiguration ) -> Void in configuration.applicationId = PARSE_DEVELOPMENT_APPLICATION_ID configuration.clientKey = PARSE_DEVELOPMENT_CLIENT_KEY configuration.server = "https://api.parse.com" }))

I have used Parse (1.12.0) SDK in this App.

When I start my iOS App, I'm getting following error message.

2016-02-02 12:42:59.684 MyParseApp[5101:61497] [Error]: Failed to run command eventually with error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

Could you assist me here what is wrong ? Any suggestion/assistance would be highly appreciated.

Thank you.

jaydeep82 avatar Feb 02 '16 07:02 jaydeep82

This is pointing at api.parse.com instead of a parse-server instance, but I'm curious if @nlutsenko sees anything else strange here.

gfosco avatar Feb 02 '16 07:02 gfosco

Thank you Fosco for quick reply.

I've migrated the code to my aws ec2 server and database on mongolab.

Using curl, I'm able to call the cloud function, insert data in mongodb, get data from mongodb.

But in iOS(Swift) App, I'm getting following error message :

2016-02-02 11:39:59.718 MyApp[4168:43783] [Error]: schema mismatch for _Session.createdWith; expected map but got object (Code: 111, Version: 1.12.0) error in register : schema mismatch for _Session.createdWith; expected map but got object

is it different issue ?

jaydeep82 avatar Feb 02 '16 08:02 jaydeep82

Few things:

  • Error 3840 means that we couldn't parse out the JSON response back from the server. I would recommend adding logging on the server end of things and looking into request/response trace for this call.
  • The second one is actually a client-propagation of the server error. Looks like you have a different schema already set for the createdWith property on the _Session. Looks like at some point it received a map, instead of a Parse Object and now it fails to validate since the schema is already set. I would recommend taking a look at the _Session collection object schema and making the adjustment either on the server or on the client.

nlutsenko avatar Feb 02 '16 08:02 nlutsenko

Hope this helps, let us know if there is anything we missed or anything that is not quite clear.

nlutsenko avatar Feb 02 '16 08:02 nlutsenko

Hi Nikita, thank you very much for your quick reply.

Regarding second issue, this class/collection _Session is part of my Parse Application and generated by Parse. Actually I've migrated this data from Parse to Mongodb hosted on MongoLab.

"createdWith" : {
        "action" : "login",
        "authProvider" : "password"
    }

I've not done any manual changes in _Session schema. Is this schema mismatch issue because of database migration from parse to mongodb ?

jaydeep82 avatar Feb 02 '16 10:02 jaydeep82

Adding /parse to the end of my configuration.server url worked for me.

latne1ec avatar Feb 02 '16 15:02 latne1ec

Hi @latne1ec , Thank you for your reply.

Could you share more details about which platform you have used for parse deployment ? I've used heroku and mongolab.

I've also added /parse to the end of my configuration.server url.

jaydeep82 avatar Feb 03 '16 05:02 jaydeep82

I set up an ec2 instance on aws to host my mongodb database and heroku for the parse-server api.

latne1ec avatar Feb 03 '16 17:02 latne1ec

@gfosco isn't the API URL for parse https://api.parse.com/1/

flovilmart avatar Feb 06 '16 00:02 flovilmart

I had the same problem and added parse at the end of the server URL and it worked. Thank you latne1ec!!!!

KathleenFMalone avatar Mar 09 '16 00:03 KathleenFMalone

/parse at the end of the url worked for me too.

michael-mckenna avatar Mar 19 '16 15:03 michael-mckenna

I added /parse and it is not working for me. I have the same issues as @jaydeep82, I am also using Heroku with mongolab. I have tried two different ways to do this in swift, but I still get the same error. These are the two ways I have done it:

let configuration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in

        ParseMutableClientConfiguration.applicationId = "appID"
        ParseMutableClientConfiguration.clientKey = "appMasterKey"
        ParseMutableClientConfiguration.server = "https://MyAppName.herokuapp.com/parse"
    })

    Parse.initializeWithConfiguration(configuration);

and I also tried:

let configuration = ParseClientConfiguration { $0.applicationId = "appID" $0.clientKey = "appMasterKey" $0.server = "https://MyAppName.herokuapp.com/parse" }

    Parse.initializeWithConfiguration(configuration)

Both ways I still get error code of 3840 "JSON text did not start with array or object and option to allow fragments not set."

2016-03-24 11:20:31.538 ClockIn[4668:676920] Warning: A long-running operation is being executed on the main thread. Break on warnBlockingOperationOnMainThread() to debug. Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

Either of these work if I use https://api.parse.com/1/ for the server, but does not work if I try to use my own server. Does anyone know why this is happening, or is it just broken when using iOS and swift?

rendragon83 avatar Mar 22 '16 22:03 rendragon83

I just tried migrating my app to Heroku. Some things work, others do not. I am getting the error "JSON text did not start with array or object and option to allow fragments not set" when saving objects.

My app is configured using:

[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id configuration) { configuration.applicationId = @"xxxxx"; //configuration.clientKey = @""; configuration.server = @"http://myappname.heroku.com/parse"; }]];

It all works fine when pointing to the parse servers

Any help? Suggestions?

bchapin avatar Apr 20 '16 23:04 bchapin

I am now getting the same issue as @bchapin

a9austin avatar Apr 21 '16 16:04 a9austin

Can you open a new issue and include some logs for what exactly is happening? We can't debug with such a vague description.

drew-gross avatar Apr 22 '16 01:04 drew-gross

Is there a new issue for this ? I am facing the same issue and pretty much stuck .. Is there a solution for this ?

angirasg avatar Apr 24 '16 14:04 angirasg

Exact same issue for me as @rendragon83 , competely stuck. If anyone managed to sort this please comment.

wincyss1 avatar Apr 28 '16 16:04 wincyss1

Any solution for this will be greatly appreciated ,,, we are stuck

angirasg avatar May 02 '16 00:05 angirasg

+1 Got the same problem. But with PFCloud.callFunctionInBackground()

ChrisBeeson avatar May 02 '16 10:05 ChrisBeeson

Getting the same problem. I have parse installed on AWS Elastic Bean Stalk with database on mLab.

This happens very randomly.

2016-05-02 09:43:43.631 app[1387:388806] [Error]: Failed to run command eventually with error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

2016-05-02 09:43:43.694 app[1387:388806] [Error]: Failed to run command eventually with error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

2016-05-02 09:43:43.755 app[1387:388806] [Error]: Failed to run command eventually with error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

candork avatar May 02 '16 14:05 candork