Creating a Category with permissions via the API

(Erik Chan) #1

I’ve been trying to create a category with the ruby API and setting the permissions. I’ve tried most variations of the permissions hash with no luck. This is what I believe is the most correct command:

response = client.create_category(name: "test", color: "f44d3c", text_color: "ffffff", description: "helloworld", permissions: {"test_group" => 1})

Unfortunately no permissions are set with this call. And the category is still open to ‘everyone’ instead of only to ‘test_group’

This is what the API doc says

  # :color and :text_color are RGB hexadecimal strings
  # :permissions is a hash with the group name and permission_type which is an integer 1 = Full 2 = Create Post 3 = Read Only
  def create_category(args)
    args = API.params(args)
              .required(:name, :color, :text_color)
              .optional(:description, :permissions)
              .default(parent_category_id: nil)
    response = post("/categories", args)

Mass create categories
(Mittineague) #2

I’m revealing my ignorance here, but is this correct syntax?
permissions: {"test_group" => 1}

In other languages that I’m more familiar with (eg. PHP, JavaScript) it would be a “mix” of Array and Object syntax

(Erik Chan) #3

Is that what i have.?

(Mittineague) #4

Maybe not

The syntax looks correct according to

(Erik Chan) #5
permissions: {"test_group" => 1}

sorry hows this different?

(Mittineague) #6

From JavaScript and PHP?

Array [“key” => “value”]
Object {“property” : “value”}

(David) #7

This post was ages ago - I’m having the exact same issue in python using…

    "permissions": { "admins": 2 }

Was any one able to figure this out?