Question

I am receiving the error when running the code:

ubuntu@ubuntu-VirtualBox:~$  curl -X POST http://localhost:5984/books/_temp_view?group=true -H "Content-Type: application/json" -d '{

"map": "function(doc) { if (doc.formats) { for (var i in doc.formats) { emit(doc.formats[i]); } } }", "reduce": "_count" }' {"error":"bad_request","reason":"invalid_json"} ubuntu@ubuntu-VirtualBox:~$

Was it helpful?

Solution

You're probably having problems with spacing or quotes in the shell. Try saving your JSON in a file, then pass that file name to curl instead of writing the JSON on the command line.

Example assuming your JSON lives in /tmp/ex.json:

curl -XPOST -Hcontent-type:application/json -d@/tmp/ex.json http://localhost:5984/books/_temp_view?group=true
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top