I am on a Windows platform and I have a file called agent_import.json in a c:\Temp directory.
The file contains the following test JSON document(s) which to my knowledge is valid JSON:
{
docs: [{
"_id": "11",
"name11": "test11"
}, {
"_id": "12",
"name12": "test12"
}]
}
I have a CouchDB installation and test database called agents installed on Windows.
From the cURL command line I execute:
curl -vX POST -H "Content-Type":"application/json" -d @c:\Temp\agent_import.json http://127.0.0.1:5984/agents/_bulk_docs
The above curl command fails, complaining about the JSON.
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> POST /agents/_bulk_docs HTTP/1.1
> Host: 127.0.0.1:5984
> User-Agent: curl/7.48.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 25
>
* upload completely sent off: 25 out of 25 bytes
< HTTP/1.1 400 Bad Request
< Server: CouchDB/1.6.1 (Erlang OTP/R16B02)
< Date: Wed, 27 Apr 2016 16:42:51 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 48
< Cache-Control: must-revalidate
<
{"error":"bad_request","reason":"invalid_json"}
* Connection #0 to host 127.0.0.1 left intact
I have tried changing the content of the Json file so that every double quote is proceeded with a backslash as listed below but alas the same error as above...
{
docs: [{
\"_id\": \"11\",
\"name11\": \"test11\"
}, {
\"_id\": \"12\",
\"name12\": \"test12\"
}]
}
I have seen people post similar issues but not exactly the same so I wanted to ask if I am doing something obviously wrong here with regards to the use of my curl command and/or my expectations of _bulk_docs.
Regards