Which directory should I place my json file, in order to import it into couchdb
I'm new to CouchDB, I have successfully installed and i'm able to use curl to create a database.
However I want to import a json file to the database.
This is what I have done.
C:Users*****>curl -X PUT http://localhost:5984/mydatabase
{"ok":true}
But when I try to import a json file, I get this error
C:Users*****>curl -X POST http://localhost:5984/mydatabase -H 'Content-Type: application/json' -d @q2.json Warning: Couldn't read data from file "q2.json", this makes an empty POST. {"error":"bad_content_type","reason":"Content-Type must be application/json"} curl: (6) Could not resolve host: curl: (6) Could not resolve host: application
My question is, in which directory should I place my json file ?
This has nothing to do with couchDB but with curl and running commands from the command line.
I think that the file should be in the same folder as you're running the curl command from (since you're addressing it as q2.json).
And I don't think the inside your curl command is helping you eighter, try it without.
To add a document to couchDB you need to give it an ID, your curl should look something like this:
curl -X PUT http://localhost:5984/mydatabase/foo -H 'Content-Type: application/json' -d @q2.json
链接地址: http://www.djcxy.com/p/48552.html
上一篇: ESP8266客户端连接到MongoDB