Reputation: 689
I am trying to setup a CouchDB database replication but both is not working via Futon and cURL/CLI: It ends up with the following error message in both cases:
{"error":"unauthorized","reason":"unauthorized to access or create database table1"}
curl -X POST http://127.0.0.1:5984/_replicate -d '{"source": "table1",
"user_ctx": {"name": "", "roles": ["admin"]}, "target":
"http://username:password@server:5984/table1", "create_target": false,
"continuous": true}' -H "Content-Type: application/json"
The target database is secured via a username and password and for HTTP basic authentication i added the credentials as you can see. The same error appears when i create a replication document via Futon.
Thanks for your help.
Upvotes: 4
Views: 2944
Reputation: 59
It is a little bit late but I think you need it.
(CouchDb 1.6.1)
https://wiki.apache.org/couchdb/Replication
POST /_replicate HTTP/1.1
{
"source": {
"url":"https://example.net:5984/table1",
"headers":{
"Authorization":"Basic Ym9iQGV4YW1wbGUuY29tOnBhc3N3b3Jk"
}
},
"target":"target1",
"create_target": false,
"continuous": true
}
where the base64 string following the word "Basic" is the output of:
https://example.net:5984
.http://server:5984/table1
" -->> table1curl -X POST http://127.0.0.1:5984/_replicate
-d '{
"source": {
"url":"https://example.net:5984/table1",
"headers":{
"Authorization":"Basic Ym9iQGV4YW1wbGUuY29tOnBhc3N3b3Jk"
}
},
"target":"target1",
"create_target": false,
"continuous": true
}' -H "Authorization: Basic dXNlcm5hbWUyOnBhc3N3b3JkMg==;Content-Type: application/json"
Ym9iQGV4YW1wbGUuY29tOnBhc3N3b3Jk : username:password (base64)
username2:password2 : admin name and password of the database target1 (on http://server:5984
)
127.0.0.1:5984
)Upvotes: 5