Hitting the Admin Rest API, Add User 301


#1

Trying to hit the Admin Rest API of Sync-Gateway version 2.1
The request is made in a nodejs app

var options = {
      method: 'POST',
      url: `http://localhost:4985/db/_user/`,
      body: {
        name,
        password,
        admin_channels,
        admin_roles,
        disabled
      },
      json: true
    }
request-promise(options)

This is giving me a 301, and I’m assuming it has to do with how node makes the request and SG thinking node isn’t on the host machine
I’m unsure where this endpoint could have been moved to?
I’m running sync-gateway in a docker container
I’m also port forwarding correctly that I can make requests with postman and curl to add users
When I simply hit the admin endpoint with

var options = {
  method: 'GET',
  url: `http://localhost:4985`,
}
return rp(options)

I get

conenction {"ADMIN":true,"couchdb":"Welcome","vendor":{"name":"Couchbase Sync Gateway","version":"2.1"},"version":"Couchbase Sync Gateway/2.1.2(2;35fe28e)"}


#2

Have you tried to GET users from your sync-gateway using the same endpoint from nodejs? The url path works for me, it seems working for you too through postman and curl. I am not sure if request-promise add anything or how nodejs makes rest api calls.

I tried this:
POST /db/_user/ HTTP/1.1
Host: 192.168.33.13:4985
Content-Type: application/json
cache-control: no-cache
Postman-Token: f2618b8c-a365-43a1-92ce-f2d87c3b3e60
{“admin_roles”: [“admin_role”], “password”: “pass”, “name”: “testuser”, “admin_channels”: }------WebKitFormBoundary7MA4YWxkTrZu0gW–

and I got HTTP response code 201.