Reputation: 105
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.
Upvotes: 4
Views: 3919
Reputation: 11
In order not to write all the json part manually, as you use powershell, you should try PSCouchDB.
Replicas as well:
PS >using module PSCouchDB
PS >$rep = New-Object PSCouchDBReplication -ArgumentList 'main','main_rep'
PS >$rep.SetContinuous()
PS >New-CouchDBReplication -Data $rep -Authorization "admin:password"
reference: https://pscouchdb.readthedocs.io/en/latest/server.html#create-replica
Upvotes: 0
Reputation: 29469
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.
Upvotes: 7
Reputation: 1969
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/
Upvotes: 0