0

for anyone that is working with kinvey console - I am trying to make simple post request via the API console to a custom endpoint but getting jsonParse error.

The enpoint code is -

 function onRequest(request, response, modules){
    modules.logger.info(request.body.name + " has " + request.body.eyes + " eyes.");
    response.complete(200);
}

The request -

POST https://baas.kinvey.com/rpc/kid_TVdEjbOoXi/custom/test HTTP/1.1
Authorization: "xxx" //my authorization number
X-Kinvey-API-Version: 3
Content-Type: application/json

{
  "name": "Fred Jones",
  "eyes": "Blue"
}

The response

HTTP/1.1 400
Content-Type: application/json
X-Kinvey-Request-Id: "XXX" // the request id
X-Powered-By: Express

{
  "error": "JSONParseError",
  "description": "Unable to parse the JSON in the request",
  "debug": "Unexpected token a"
}

Anyone know what is the problem?

uzb
  • 229
  • 1
  • 5

1 Answers1

1

I'm an engineer at Kinvey, and can help ya out.

Try wrapping the Content-Type header value in quotes, so it can be parsed as a String:

POST https://baas.kinvey.com/rpc/kid_TVdEjbOoXi/custom/test HTTP/1.1
Authorization: "xxx" //my authorization number
X-Kinvey-API-Version: 3
Content-Type: "application/json"    <---- note the addition of "

{
  "name": "Fred Jones",
  "eyes": "Blue"
}
edthethird
  • 6,263
  • 2
  • 24
  • 34