API for changing category groups

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 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

I tried that too

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