# Adding user to group from API gets "BAD CSRF"

**URL:** <https://meta.discourse.org/t/adding-user-to-group-from-api-gets-bad-csrf/66430>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [July 19, 2017, 10:11am UTC](https://meta.discourse.org/t/adding-user-to-group-from-api-gets-bad-csrf/66430 "2017-07-19T10:11:39Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [July 19, 2017, 10:11am UTC](https://meta.discourse.org/t/adding-user-to-group-from-api-gets-bad-csrf/66430/1 "2017-07-19T10:11:39Z")

</div>

I’m trying to add a user to a group via the API. From the docs and from what I see happening when I add a user from the web browser, it appears that this should work, but I’m getting “BAD CSRF”

```plaintext
curl -H 'Content-Type: application/json' -X PUT -d '{"api_key":"THE_KEY", "api_username":"system", "usernames":"joeuser" }' https://community.mysite.com/groups/42/members.json

```

I’m stumped. Is there something obviously silly I’m doing here?

---

_[View the full topic](https://meta.discourse.org/t/adding-user-to-group-from-api-gets-bad-csrf/66430)._
