I wish to add and remove group owners using the API. This is not documented in the api docs.
Tracing the calls while logged in as admin, make user owner is
PUT groups/<gid>/owners
with a payload of usernames=nikkilocke
(note no admin!)
Remove user from owners is
DELETE admin/groups/<gid>/owners
with a payload of user_id=<uid>
Studying the source code shows:
def group_add_owners(group_id, args)
args = API.params(args).required(:usernames).to_h
put("/admin/groups/#{group_id}/owners.json", group: args)
end
def group_remove_owners(group_id, args)
args = API.params(args).required(:usernames).to_h
delete("/admin/groups/#{group_id}/owners.json", group: args)
end
and this code doesn’t seem to have changed since 2023.
I am running Discourse 3.4.7, and the add owners entry point in the source code gives a 404 error.
Urls I have tried:
PUT /groups/384/owners usernames=nikkilocke
OK
PUT /admin/groups/384/owners group[usernames]=nikkilocke
404 error
DEL /admin/groups/384/owners group[usernames]=nikkilocke
OK
DEL /admin/groups/384/owners user_id = 12
OK
Can anyone advise me what’s going on, and which urls to use for this, please?