# Group\_permissions using api in python

**URL:** <https://meta.discourse.org/t/group-permissions-using-api-in-python/81813>\
**Category:** Product Support\
**Created:** [February 28, 2018, 7:04pm UTC](https://meta.discourse.org/t/group-permissions-using-api-in-python/81813 "2018-02-28T19:04:18Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![David\_fs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david_fs/32/88716_2.png) [@David\_fs](https://meta.discourse.org/u/David_fs)\
**Post date:** [March 1, 2018, 4:57pm UTC](https://meta.discourse.org/t/group-permissions-using-api-in-python/81813/4 "2018-03-01T16:57:58Z")

</div>

ok so I think I am a step closer…

first off -

```
 permissions: {admins: 1, staff: 2} 

```

The problem though is the above is cause this error:

```
NoMethodError (undefined method `each' for "stafff":String) /var/www/discourse/app/controllers /categories_controller.rb:223:in `category_params'

```

Here’s the rub though… source code in discourse does the folowing:

```
        if p = params[:permissions]
          p.each do |k,v|
          p[k] = v.to_i
       end

```

The probelm here is `p` is not being seen as a hash in the controller.. I tried converting the permissions value to a json string hoping it would be prased by the api - so I did this:

```
permissions: json.dumps({"admins": 2, 'stafff': 3})

```

but no dice - just got this error:

```
NoMethodError (undefined method `each' for "{\"admins\": 2, \"stafff\": 3}":String)
/var/www/discourse/app/controllers/categories_controller.rb:223:in `category_params'

```

Can anyone see anything wierd or missing?

---

_[View the full topic](https://meta.discourse.org/t/group-permissions-using-api-in-python/81813)._
