I´m trying to add a group to a category via the api using postman.
Is there a way to do that ?
Yes, everything in Discourse has an API. You can learn the API endpoints for stuff you see in the UI using How to reverse engineer the Discourse API
Isn’t there a other way to do it ?
I’m trying to assign a group to a category, so only people in that group can see this category.
I know that there are some similar questions out there, where you can reverse engineer DIscourse.
I want to change the marked property on the picture
In the second picture you can see what i tried inside postman
The number used in the request i got from trying to reverse engineer it as seen in the last picture
Did I make some mistake in my put request?
The _ parameter isn’t actually required - it is just there as a “cache buster”. You can remove it.
Also, you are looking at the incorrect request in your developer tools. You should be looking at the request that happens when you click the “save” button. (You will need to tick “preserve log” in dev tools so that the request doesn’t dissappear when the page reloads). Look for a PUT request to /categories/192.
Another thing to watch out for is that your parameters need to be urlencoded. In postman, you do this by changing from “form-data” to “x-www-form-urlencoded”.
Hope that helps get you a little bit closer!
Thanks for the reply.
I can´t seem to find the right request
Okay. I Think i found the right request.
As seen in the picture below, then i want to change the permissions array.
I tried doing that inside postman, my put request returns bad request
You should not be using the “raw” option on postman
This is what I use when creating a category - I tend to use the form data however
Another thing to check is your error logs - this helps you along the path to be able to identify any calls are incorrect
Does it work?
And do you call your group name “1” ?
no the name of the group goes in the [groupname] section
It does work - I use that exact set up all the time.
So I could write permissons[random grop name]?
works for me - as long as the group exists of course first.
I will try that later. Thanks for the replay
It worked. Thanks man. You a lifesaver
你好,@Edwin_Silva 和 @mikechristopher
我正在尝试应用这里的经验,但遇到了问题。
在我的情况下,我不是在创建具有组访问权限的类别,而是在向现有类别添加一个组。
当我应用上述经验时,会收到一个错误,提示子类别没有对其父类别的访问权限。
如果我为类别已有的每个组名称指定 permissions[group_name],则不会出现错误。因此,我至少知道问题所在。我认为我只是设置了一个权限,而移除了其他权限。
现在我想知道,是否有可能只添加一个新的组权限,而无需设置整个权限集。
你们愿意帮忙吗?
slim







