Hello.
Just trying to make new API work in Python here.
Removing groups works fine as nothing seems to be required in arguments.
Adding groups always pops with a message saying that ‘type’ is missing ? I can’t see in the docs anything mentioned about another parameter to mention other than the group name.
Detailed error :
HTTPError: Unexpected token (END_OBJECT), expected FIELD_NAME: missing property ‘type’ that is to contain type id (for class com.atlassian.confluence.api.model.people.Group)
at [Source: com.atlassian.confluence.plugins.restapi.filters.LimitingRequestFilter$1@64b4bfdd; line: 1, column: 22]
Removing or adding users to a group also fails. Bad request or something about null… I use the correct PUT / DELETE method and URL. Authentication is fine as the remove_group works fine and so are all other functions.
Here’s the code of my functions :
def create_group(self, name):
"""
Create a group by given group parameter
:param name: str
:return: New group params
"""
url = "rest/api/admin/group"
data = {"name": name}
return self.post(url, data=data)
def remove_group(self, name):
"""
Delete a group by given group parameter
If you delete a group and content is restricted to that group, the content will be hidden from all users
:param name: str
:return:
"""
log.warning("Removing group...")
url = "rest/api/admin/group/{groupName}".format(groupName=name)
try:
response = self.delete(url)
except HTTPError as e:
if e.response.status_code == 404:
# Raise ApiError as the documented reason is ambiguous
raise ApiError(
"There is no group with the given name, "
"or the calling user does not have permission to delete it",
reason=e,
)
raise
return response
def add_user_to_group(self, username, group_name):
"""
Add given user to a group
:param username: str
:param group_name: str
:return: Current state of the group
"""
url = "rest/api/user/{username}/group/{groupName}".format(username=username, groupName=group_name)
return self.put(url)
def remove_user_from_group(self, username, group_name):
"""
Remove given user from a group
:param username: str
:param group_name: str
:return:
"""
log.warning("Removing user from a group...")
url = "rest/api/user/{username}/group/{groupName}".format(username=username, groupName=group_name)
try:
response = self.delete(url)
except HTTPError as e:
if e.response.status_code == 404:
# Raise ApiError as the documented reason is ambiguous
raise ApiError(
"There is no group with the given name, "
"or the calling user does not have permission",
reason=e,
)
raise
return response
Anyone here made it work my any chance ?
Thx