Setting Fisheye group permissions via REST API

Gerald Schneider
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 4, 2023

I need to replace the permissions of a number of user groups because the groups are going to be renamed in Active Directory.

Due to the number of affected groups and repositories I need to do this automatically and I'm trying to use the REST API for this.

I can retrieve the groups and their permissions without problems, but I have trouble setting the new permissions because the documentation is incomplete:

https://docs.atlassian.com/fisheye-crucible/latest/wadl/fecru.html

If you expand the acceptable request representations part for PUT requests it's just empty. The examples from other PUT requests is not helping either.

The link to the REST API Examples from the documentation leads to a 404 and I can't find it anywhere else.

This is my python function to set the permissions for the new group name:

    def repository_permissions_add(self, repository: str, group: str, permissions: object):
        json_data = json.dumps({ 'permissions': permissions })
        print(json_data)
        response = self._put(self.fecru_url + "/rest-service-fecru/admin/repository-permissions/%s/groups/%s" % (repository, group),
                             data=json_data)
        print(response.status_code)
        print(response.text)
The json_data that is sent with the request looks like this:
{"permissions": ["CAN_READ", "IS_ADMIN"]}
The server responds with a 500 error and the following error message:
Can not deserialize instance of java.util.HashSet out of START_OBJECT token\n at [Source: HttpInputOverHTTP@4b333640[c=41,q=0,[0]=null,s=STREAM]; line: 1, column: 1]
Can anybody point me to the current location of the examples, or where to find the proper data I need to send along the request?

1 answer

1 accepted

1 vote
Answer accepted
Gerald Schneider
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 8, 2023

I figured it out. The JSON Fisheye expected was wrong, it should only contain the permissions, with nothing around it.

['CAN_READ', 'IS_ADMIN']

Additionally, newer versions of the requests library have a json= parameter, which makes it even easier.

My function is now only:

    def repository_permissions_add(self, repository: str, group: str, permissions: object):
        response = self._put(self.fecru_url + "/rest-service-fecru/admin/repository-permissions/%s/groups/%s" % (repository, group),
                            json=permissions)

 

Gerald Schneider
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 8, 2023

Note: The DELETE method expects the same JSON as the PUT method.

Like Steffen Opel _Utoolity_ likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
4.8.13
TAGS
AUG Leaders

Atlassian Community Events