# Discourse Add Group API

**URL:** https://meta.discourse.org/t/discourse-add-group-api/25571
**Category:** Bug
**Created:** [February 23, 2015, 3:28pm UTC](https://meta.discourse.org/t/discourse-add-group-api/25571 "2015-02-23T15:28:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dansingerman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dansingerman/32/115687_2.png) [@dansingerman](https://meta.discourse.org/u/dansingerman)
#### Post date: [February 23, 2015, 3:28pm UTC](https://meta.discourse.org/t/discourse-add-group-api/25571/1 "2015-02-23T15:28:29Z")

</div>

I am using the discourse\_api gem, and adding a group fails as follows:

```
client = DiscourseApi::Client.new
client.create_group(name: "some_group")
DiscourseApi::Error: {"errors"=>["Name must be at least 3 characters"]}

```

This is because of a mismatch between what the gem posts, and what the API expects.

The gem posts

```
{
    "group": {
        "name": "some_group",
        "visible": "true"
    }
}

```

But the controller method does not expect the root ‘group’ key:

```
 group = Group.new

 group.name = (params[:name] || '').strip

```

The discourse api documentation does not seem to mention groups: [Discourse REST API Documentation](https://meta.discourse.org/t/discourse-api-documentation/22706)

I am happy to fix this bug, but wanted to ask what we think the correct API design here is - should we fix it by removing the root element from the packet posted by the gem, or should the controller method be changed to deal with the root element?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 23, 2015, 3:48pm UTC](https://meta.discourse.org/t/discourse-add-group-api/25571/2 "2015-02-23T15:48:47Z")

</div>

> [@dansingerman](#):
>
> should we fix it by removing the root element from the packet posted by the gem

Yes, please 😍 .

I changed the API recently but didn’t update the gem 😳

---

<div class="post-metadata">

### Author: ![dansingerman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dansingerman/32/115687_2.png) [@dansingerman](https://meta.discourse.org/u/dansingerman)
#### Post date: [February 25, 2015, 11:33am UTC](https://meta.discourse.org/t/discourse-add-group-api/25571/3 "2015-02-25T11:33:27Z")

</div>

Here is the PR 😄

[https://github.com/discourse/discourse\_api/pull/68](https://github.com/discourse/discourse_api/pull/68)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 25, 2015, 11:46am UTC](https://meta.discourse.org/t/discourse-add-group-api/25571/4 "2015-02-25T11:46:33Z")

</div>


