对于任何使用kinvey控制台的人,我都试图通过API控制台向自定义端点发出简单的post请求,但是得到了jsonParse错误。
enpoint代码是-
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"
}有人知道问题出在哪里吗?
发布于 2013-12-02 16:34:19
我是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"
}https://stackoverflow.com/questions/20325307
复制相似问题