Post 调试小代码-接收错误
我在运行代码时收到错误:Post 调试小代码-接收错误,post,curl,couchdb,Post,Curl,Couchdb,我在运行代码时收到错误: ubuntu@ubuntu-VirtualBox:~$ curl -X POST http://localhost:5984/books/_temp_view?group=true -H "Content-Type: application/json" -d '{ “地图”:“功能(文档){ 如果(文档格式){ 用于(文件格式的var i){ 发射(文件格式[i]); } } }", “减少”:“\u计数” }' {“错误”:“错误的请求”,“原因”:“无效的jso
ubuntu@ubuntu-VirtualBox:~$ curl -X POST http://localhost:5984/books/_temp_view?group=true -H "Content-Type: application/json" -d '{
“地图”:“功能(文档){
如果(文档格式){
用于(文件格式的var i){
发射(文件格式[i]);
}
}
}",
“减少”:“\u计数”
}'
{“错误”:“错误的请求”,“原因”:“无效的json”}
ubuntu@ubuntu-虚拟箱:~$
您可能在shell中的空格或引号方面有问题。尝试将JSON保存在文件中,然后将该文件名传递给curl,而不是在命令行中写入JSON 假设您的JSON位于/tmp/ex.JSON中的示例:
curl -XPOST -Hcontent-type:application/json -d@/tmp/ex.json http://localhost:5984/books/_temp_view?group=true