Parse PFCloud – “JSON text did not start with array or object”

It’s always the little things that lead to flatter foreheads (or at least it is for me).

Banging my head against the desk this evening working on a Parse migration, I finally figured out what was causing an error condition in a PFCloud function call.

The request to the server succeeded, but the response was malformed somehow:

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.}

“What?? I know the response is supposed to be JSON – I can even test it out and it works great in Postman.”

Weeeelll, it turns out that if you don’t get the URL to your self-hosted Parse Server correct, you’re going to get a response that’s not JSON. Doh!

I had left off the “/parse” portion of the URL to my self-hosted parse server:

So, the bottom-line take-away? Make sure you get the full URL to your self-hosted Parse Server set to the server property of your ParseClientConfiguration instance. That endpoint could vary based on how you deployed the server to your cloud host of choice. For me, it was my goofy mistake of leaving off “/parse”.

Go forth and may your forehead be ever-more round than mine.

  • Pushparaj Samant

    You saved me man. Thanks for this.

  • Todd

    Thank you, thank you, thank you!