Unexpected token u in JSON at position 0

Hi! Thanks for the tutorial is really great, I was able to successfully add items to the database with CLI, but when I tried with iOS or postman I always got this error.

Could you please help me what I did wrong?

iOS response:

Response body:
{"statusCode":500,"headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":true},"body":"{\"error\":\"Unexpected token u in JSON at position 0\"}"}

    body = "{\"error\":\"Unexpected token u in JSON at position 0\"}";
    headers =     {
        "Access-Control-Allow-Credentials" = 1;
        "Access-Control-Allow-Origin" = "*";
    statusCode = 500;

Which endpoint is causing this error? Or rather how are you triggering this error?

I am calling the api in the iOS

This is a JSON parse error, which means the JSON in the body of your request is not well formed. What does the body of the request look like before you parse it?

This has tripped me up a time or two when posting JSON in request bodies. Keep in mind that the JSON being sent in the request body is a string representation of the JSON. As such, it will need to be escaped. For example:

1 Like