Jin Ma
Jin Ma

Reputation: 243

dremio list user API

I'm trying to query dremio using the documented API to get list of users. Dremio version:

Build
20.2.2-202203241726030461-f7eea3e0
Edition
Enterprise Edition

API: https://docs.dremio.com/software/rest-api/user/list-users/ sample query:

curl -X GET --location "http://localhost:9047/api/v3/user" \
    -H "Authorization: _dremiohrr395nv31g8k610616tucp91g" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json"

I keep getting this error:

{
    "errorMessage": "Something went wrong. Please check the log file for details, see https://docs.dremio.com/advanced-administration/log-files.html",
    "moreInfo": "HTTP 405 Method Not Allowed"
}

It seems that this API is not supported at all.

Is there a published API to list all users so that I can get user name, uid, and role memberships? I'm trying to avoid using SQL query.

Upvotes: 0

Views: 460

Answers (2)

markc
markc

Reputation: 2158

There isn't a "list all users" API for Dremio - there are a couple of ways you can do this:

1 - Run a SELECT * from sys.users using the SQL API and then fetch the results

2 - Use the v2 API which isn't the "official" client API that you see in the docs, more its an API used by the UI and some other clients and could be changed / deprecated without warning. (the observant user will notice these calls made from the UI when using dev tools in your favourite browser)

Simple example using curl

% curl -H 'Content-Type: application/json' -X POST http://127.0.0.1:9047/apiv2/login -d '{
             "userName":"mc",
             "password":"xxxx"
        }' | jq '.token'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   843  100   766  100    77   5410    543 --:--:-- --:--:-- --:--:--  5978
"ftrvctk4n634qiqdikbhahdk8d"

Take this token and then append it like so

% curl -H 'Content-Type: application/json' -H 'Authorization: _dremioftrvctk4n634qiqdikbhahdk8d' -X GET "http://127.0.0.1:9047/apiv2/users/all/?pretty"
{
  "users" : [ {
    "resourcePath" : "/user/mc",
    "userName" : "mc",
    "userConfig" : {
      "uid" : {
        "id" : "5bb96e81-96dc-47e3-b69e-8dfc255dfd70"
      },
      "userName" : "mc",
      "firstName" : "Mark",
      "lastName" : "C",
      "email" : "[email protected]",
      "groups" : [ ],
      "groupInfos" : [ ],
      "createdAt" : 1724251526446,
      "modifiedAt" : 1724251526441,
      "version" : "Mwp3BAv96eQ=",
      "type" : "LOCAL",
      "active" : true,
      "createdBy" : "LOCAL"
    },
    "links" : {
      "self" : "/user/mc"
    },
    "name" : "mc",
    "id" : "5bb96e81-96dc-47e3-b69e-8dfc255dfd70"
  } ]
}%

Upvotes: 0

Jin Ma
Jin Ma

Reputation: 243

v3 list users API is buggy.

user apiv2/user works

Upvotes: 0

Related Questions