根据此https://docs.cloudant.com/document.html#bulk-operations 我正在尝试将多个文档插入到我的 cloudant 数据库中,但出现错误:
{
"error": {
"statusCode": 400,
"name": "Error",
"request": {
"method": "POST",
"headers": {
"content-type": "application/json",
"accept": "application/json"
},
"uri": "https://XXXXXX:XXXXXX@8f7fc7f0-766b-4429-b060-4ef1c01f7665-bluemix.cloudant.com/ttt/_bulk_docs",
"body": "[{\"name\":\"Nicholas\",\"_id\":\"96f898f0-f6ff-4a9b-aac4-503992f31b01\",\"_attachments\":{},\"age\":45,\"gender\":\"male\"},{\"name\":\"Taylor\",\"_id\":\"5a049246-179f-42ad-87ac-8f080426c17c\",\"_attachments\":{},\"age\":50,\"gender\":\"male\"},{\"name\":\"Owen\",\"_id\":\"d1f61e66-7708-4da6-aa05-7cbc33b44b7e\",\"_attachments\":{},\"age\":51,\"gender\":\"male\"}]"
},
"description": "couch returned 400",
"scope": "couch",
"reason": "Request body must be a JSON object",
"error": "bad_request",
"stack": "Error: Request body must be a JSON object\n at Request._callback (/nodejsAction/node_modules/cloudant-nano/lib/nano.js:247:15)\n at Request.self.callback (/nodejsAction/node_modules/request/request.js:186:22)\n at emitTwo (events.js:106:13)\n at Request.emit (events.js:191:7)\n at Request.<anonymous> (/nodejsAction/node_modules/request/request.js:1081:10)\n at emitOne (events.js:96:13)\n at Request.emit (events.js:188:7)\n at IncomingMessage.<anonymous> (/nodejsAction/node_modules/request/request.js:1001:12)\n at IncomingMessage.g (events.js:291:16)",
"message": "Request body must be a JSON object",
"errid": "non_200",
"headers": {
"statusCode": 400,
"x-couchdb-body-time": "0",
"cache-control": "must-revalidate",
"uri": "https://XXXXXX:XXXXXX@8f7fc7f0-766b-4429-b060-4ef1c01f7665-bluemix.cloudant.com/ttt/_bulk_docs",
"x-cloudant-backend": "bm-cc-dal-01",
"date": "Sat, 20 May 2017 12:11:37 GMT",
"content-type": "application/json",
"via": "1.1 lb1.bm-cc-dal-01 (Glum/1.34.0)",
"x-couch-request-id": "fed1512052",
"x-content-type-options": "nosniff",
"strict-transport-security": "max-age=31536000"
}
}
}
我从示例文档中获取了输入 Json 并在线检查了 JSON 验证器,它似乎没问题。我做错了什么?