2

I have a running instance of a sync gateway which is connected with a data bucket. I configured the gateway with an initial user:

"firstuser": {
    "disabled": false,
    "password": "abc"
}

The sync gateway webview shows exactly this single user. Now I want to add another user via the REST api:

curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST -d '{"name":"raphi", "password":"abc"}' http://192.168.1.150:4995/_admin/db/test/_user/

or

curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT -d '{"password":"abc"}' http://192.168.1.150:4995/_admin/db/test/_user/raphi

The result is that no user is created, the webview still shows only one (the initial) user. Additionally, I get a useless html-code answer:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv='Content-type' content='text/html; charset=utf-8'>
    <title>Couchbase Sync Gateway</title>
    <style>/* global tags */
* {
  box-sizing: border-box;
}
...
  </head>
  <body>
    <div id="container"></div>
    <script>...</script>
  </body>
</html>

EDIT: I just tried to use the authentication API by sending a POST with {"name":"raphi"} to /test/_session/. This also results in an HTML page response instead of the documented JSON data. So this seems to be a general API problem...

Bastian
  • 4,638
  • 6
  • 36
  • 55

3 Answers3

1

Stupid me! The URL was simply wrong: it should not contain _admin/db/. Therefore, the right URLs would be:

http://192.168.1.150:4995/test/_user/
http://192.168.1.150:4995/test/_user/raphi

This solved the problem for me.

Bastian
  • 4,638
  • 6
  • 36
  • 55
0
 curl -X PUT http://127.0.0.1:4985/test/demo@abc.com --data '{"password":"12345678", "name":"demo@abc.com"}'

You can check, http://127.0.0.1:4985/_admin/db/test/users

Sivailango
  • 544
  • 1
  • 6
  • 15
0
curl -H 'Content-Type: application/json' -X POST -d '{"name":"mohammad", "password":"123","admin_channels":["mohammad","public"]}' http://192.168.1.137:4985/grocery/_user/
Hamidreza Sadegh
  • 2,155
  • 31
  • 33