Assign Group to Category via Write API
-
I am not sure, can you put a
console.log(cid, privilege, group);
before this line https://github.com/NodeBB/nodebb-plugin-write-api/blob/master/routes/v2/categories.js#L78 and try again? It sounds like the correct group name is not passed to the function. Those errors are thrown from https://github.com/NodeBB/NodeBB/blob/master/src/groups/create.js#L94-L100 -
@baris said in Assign Group to Category via Write API:
curl -XPUT -H "Authorization: Bearer <TOKEN>" --data "privileges=['groups:find']&groups=['Write Group']" http://<hostname>/api/v2/categories/7/privileges
Yeah I think the curl command is still wrong try
curl -XPUT -H "Authorization: Bearer <TOKEN>" --data "privileges[]=groups:find&groups[]='Write Group'" http://<hostname>/api/v2/categories/7/privileges
-
@baris That has resolved the issue. If i want to change the privileges for more than one action what would be the format?
I tried privileges[]=groups:find,groups:read OR privileges[]={groups:find,groups:read} OR privileges[]=[{groups:find,groups:read}]
Neither works.
Kindly please advise. Thanks
-
@yapne said in Assign Group to Category via Write API:
@baris @julianlam How do i add user(s) to the category via this write API? Are you able to advise please? Thanks
Doesn't seem the API support this. Are you able to confirm please?
-
By "adding users" do you mean giving them privileges?
Edit: if that is the case, then you may find it easier to create a group for the category, give it privileges, and then use the write API to add users to the group
-
@pitaj There is a specific reason why I am not using group. Nodebb doesn't have the capability to assign user's privileges at the topic level. Hence, we are using category as a work around for this missing feature.
Externally to NodeBB, we are giving end users the functionality to create category dynamically and assign users to it. By using group, it may end up creating a lot of groups that are going to be nightmare to maintain. Therefore, i am planning to assign the users directly to the category instead. I think the API does not support this requirement just yet. If you can advise if there is another better way to do this please? Or possibly to enhance the API to assign user's privileges to the category?
Many thanks
Nelson