0

对于使用 kinvey 控制台的任何人 - 我正在尝试通过 API 控制台向自定义端点发出简单的发布请求,但收到 jsonParse 错误。

端点代码是 -

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

请求——

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

响应

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

有谁知道是什么问题?

4

1 回答 1

1

我是 Kinvey 的工程师,可以帮助你。

尝试将Content-Type标头值用引号括起来,以便可以将其解析为字符串:

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"
}
于 2013-12-02T16:34:19.887 回答