Hello,

My question is simple, there is a way to add an user to a group by REST API?

Consulting the Redash github [¹] I see some calls that the API accept but I can’t understand how I add an user to a group just with those calls.

[¹] redash/api.py at 5aa620d1ec7af09c8a1b590fc2a2adf4b6b78faa · getredash/redash · GitHub

Redash consumes its own API. So anything you can do in the application you can also do with the API. From the file you shared, it looks like you can post an array of strings with the key groups to api/users/<user_id>

1 Like

Thanks for the reply.

I didn’t have success in add a user to a group yet, but I’ll work on that

Perhaps we can help if you share an example of the request you tried and the result you received.

On the Redash Github[¹] I found these files, where I think can be the right way to add a user.

image !

I’m trying post this JSON:
{
“action”:“add_member”,
“timestamp”:“2021-02-03T17:00:35.111Z”,
“object_id”:“objectId”,
“object_type”:“group”,
“member_id”:“memberId”
}
on this URL: /api/groups/groupId/members

But every try I receive : {“message”: “Internal Server Error”}

[¹]redash/groups.py at 5aa620d1ec7af09c8a1b590fc2a2adf4b6b78faa · getredash/redash · GitHub

To add a user in a group, you just need do a POST In this URL: /api/groups/group_id/members

sending this body:

{
"user_id":"user_id",
"group_id":"group_id"
}

Glad you figured this out! I was just working on a response for you!

Important for others looking into this: the self.record_event() call shown in OP’s comment has nothing to do with the API syntax. That just logs this event to Redash’s metadata database.

1 Like