CURL CouchDB Replication command

I'm running the following line in curl trying to setup couchdb replication:

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:

{"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.


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:

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.


Looking at the CouchDB wiki I found this which could be useful to solve your issue. Basically under Windows you need to escape special characters or to write the JSON in a file and use that from the curl CLI.


I've had problems with curl and PowerShell before - my resolution was to call it from a batch file (the output put into a PowerShell variable)... thought it might be related to the way arguments were passed to curl being misinterpreted - I never got to the bottom of it as this worked...

maybe this could help http://huddledmasses.org/the-problem-with-calling-legacy-or-native-apps-from-powershell/

链接地址: http://www.djcxy.com/p/8534.html

上一篇: 如何在PHP中使用cURL连接到Tor隐藏服务?

下一篇: CURL CouchDB复制命令