# 是否有用于设置用户的主要组的API

**URL:** <https://meta.discourse.org/t/is-there-an-api-to-set-the-primary-group-for-a-user/309611>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [2024 年5 月 28 日 00:29 UTC](https://meta.discourse.org/t/is-there-an-api-to-set-the-primary-group-for-a-user/309611 "2024-05-28T00:29:24Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

作者： ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
发布日期： [2024 年5 月 30 日 04:55 UTC](https://meta.discourse.org/t/is-there-an-api-to-set-the-primary-group-for-a-user/309611/7 "2024-05-30T04:55:02Z")

</div>

> [@Onlyanegg](#):
>
> 该 gem 目前似乎还不支持。

我认为使用这些方法向 gem 不支持的路径发出请求是可以的：

> <https://github.com/discourse/discourse_api/blob/main/lib/discourse_api/client.rb#L93-L117>

所以你可以这样做：

```ruby
 response = client.put("admin/users/4/primary_group", primary_group_id: 43)

```

---

_[View the full topic](https://meta.discourse.org/t/is-there-an-api-to-set-the-primary-group-for-a-user/309611)._
