Search code examples
restcouchbasecouchbase-sync-gateway

Cannot create user in Couchbase Sync Gateway


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


Solution

  • 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.