Curl giving "Invalid UTF-8 JSON" error from CouchDb although JSON is fine? Any ideas? Curl giving "Invalid UTF-8 JSON" error from CouchDb although JSON is fine? Any ideas? curl curl

Curl giving "Invalid UTF-8 JSON" error from CouchDb although JSON is fine? Any ideas?


Thanks guys. Turns out it's a problem with quote escaping. Here's the answer I got from David on the CouchDB user mailing list:

This is a windows thing regarding quoting - a real PITA. Unfortunately cmd.exe shell on windows doesn't parse this correctly. The rules for when escaping with a "" or a ^" or a \" are a bit vague but this works:

C:\tmp>curl -X PUT http://username:password@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af -d "{\"title\":\"There is Nothing Left to Lose\",\"artist\":\"Foo Fighters\"}" {"ok":true,"id":"6e1295ed6c29495e54cc05947f18c8af","rev":"1-4b39c2971c9ad54cb37e08fa02fec636"}

C:\tmp>

"basically you need to \"escape\" all \"quotes\" within your JSON"

This fixes my problem


I also met same problem, after searching a while, I found about Git Bash in other question. Git bash has curl command inside. The git bash is included in Git installer.


You have to put the escap characterstic ** and also do not forgot to put after -d all things in **"".I.e : curl -X PUT http://127.0.0.1:5984/my_database/"001" -d "{\"Name\":\"Suresh\",\"age\":\"32\",\"Designation\":\"Associates Manager\"}"