Uploading multiple documents to couchdb giving error

主宰稳场 提交于 2019-12-13 01:56:24

问题


I have to upload bulk document into couchdb but this is not working and giving error. This is what i try to do with curl

curl -d '{"docs":[{"key":"baz","name":"bazzel"},{"key":"bar","name":"barry"}]}' -X POST http://127.0.0.1:5984/testdb/_bulk_docs

This is the error which comes for this

{"error":"bad_content_type","reason":"Content-Type must be application/json"}

This curl command is simple copy+paste from wiki of couchdb so ideally this should not be giving error. Is there anything that i am missing?


回答1:


Add the Header Content-Type application/json to your curl command. The flag is -H

e.g.

curl -H 'Content-Type: application/json' -d '{"docs":[{"key":"baz","name":"bazzel"},{"key":"bar","name":"barry"}]}' -X POST http://127.0.0.1:5984/testdb/_bulk_docs



来源:https://stackoverflow.com/questions/29938435/uploading-multiple-documents-to-couchdb-giving-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!