Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CURL CouchDB Replication command - Invalid JSON

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

curl -X POST -d '{"source":"http://user:[email protected]:5984/main","target":"main"}' -H 'Content-Type: application/json' http://user:[email protected]/_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.

like image 359
DaR Avatar asked Jan 19 '23 03:01

DaR


1 Answers

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:[email protected]:5984/main,target:main}' You need to call it like this:

curl -X POST -d '{"""source""":"""http://user:[email protected]:5984/main""","""target""":"""main"""}' -H 'Content-Type: application/json' http://user:[email protected]/_replicate

Look at http://pscx.codeplex.com/ module. EchoArgs might help when discovering such problems.

like image 200
stej Avatar answered Jan 30 '23 21:01

stej