atlassian-python-api
atlassian-python-api copied to clipboard
[Service Desk] Pagination: get_service_desks() only shows first 50 projects
Hey there,
As an admin of a Jira Server instance with more than 50 SD projects, the pagination needs to be called as well in get_service_desk() method.
I am not sure how to do this myself, I consider myself a very beginner level coder so I am lost. I only saw that the get_service_desks() method is returning the "values" of the first request made, which is limited to 50 entries. I also have issues with the authorization using the requests lib in Python directly so I'm not able to get a full list of all our SD projects.
Is there a way to feed the method get_service_desk() with any parameters that would make me go through the pages and retrieve all projects?
UPDATE: I re-wrote the method to look like this:
def get_service_desks(self):
"""
Returns all service desks in the Jira Service Desk application
with the option to include archived service desks
:return: Service Desks
"""
service_desks_list = self.get("rest/servicedeskapi/servicedesk", headers=self.experimental_headers)
values = []
while service_desks_list["isLastPage"] == False:
values = values + service_desks_list["values"]
new_url = service_desks_list["_links"]["next"].replace('[YOUR_URL]', '')
service_desks_list = self.get(new_url, headers=self.experimental_headers)
values = values + service_desks_list["values"]
return values