Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid json result when using curl under Windows #533

Open
jackeisenbach opened this issue May 4, 2015 · 1 comment
Open

Invalid json result when using curl under Windows #533

jackeisenbach opened this issue May 4, 2015 · 1 comment

Comments

@jackeisenbach
Copy link

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"""}"

@KingGeneral
Copy link

KingGeneral commented Jan 5, 2017

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"}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants