Open jackeisenbach opened 9 years ago
for it to work :
curl -X PUT http://127.0.0.1:5984/albums/70b50b \ -d {\"title\":\"Blackene\"}
**or**
curl -X PUT http://127.0.0.1:5984/albums/70 \ -d {"""title""":"""Blackene"""}
**or if 1 or more parameter**
curl -X PUT http://127.0.0.1:5984/albums/6ef -d "{\"title\":\"There isNothing Left to Lose\",\"artist\":\"Foo Fighters\"}"
**or put it in documents first (example i put json in person.json )**
curl -X POST http://127.0.0.1:5984/albums/ -d @person.json -H "Content-Type: application/json
**and put version**
curl -X PUT http://127.0.0.1:5984/mycouchdb/fo1 -d @person.json -H "Content-Type: application/json
But , not working when using this :
curl -X PUT http://127.0.0.1:5984/albums/70 \ -d '{"title":"Blackene"}'
In CouchDB The Definitive Guide, In the Core API section, under Documents, when you run the command: curl -X PUT http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af -d '{"title":"There is Nothing Left to Lose","artist":"Foo Fighters"}'
I always got: {"error":"bad_request","reason":"invalid_json"}
It took a LONG time to debug. Under Windows 7 command shell, the Quotes in JSON need to be escaped differently using curl. Here's what worked for me:
c:>curl -X PUT http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af -d "{"""title""":"""There is Nothing Left to Lose""","""artist""":"""Foo Fighters"""}"