Question:
I’m running the following line in curl trying to setup couchdb replication:
1 2 |
curl -X POST -d '{"source":"http://user:password@siteA.com:5984/main","target":"main"}' -H 'Content-Type: application/json' http://user:password@siteB.com/_replicate |
It keeps returning the following error:
1 2 |
{"error":"bad_request","reason":"invalid UTF-8 JSON"} |
As far as I can tell the JSON seems valid. Any ideas?
I’m also using Powershell as well.
Answer:
It happend many times to me as well. PowerShell parser (who knows why) removes quotes in the json.
So it sends it to curl like ‘{source:http://user:password@siteA.com:5984/main,target:main}’
You need to call it like this:
1 2 |
curl -X POST -d '{"""source""":"""http://user:password@siteA.com:5984/main""","""target""":"""main"""}' -H 'Content-Type: application/json' http://user:password@siteB.com/_replicate |
Look at http://pscx.codeplex.com/ module. EchoArgs
might help when discovering such problems.