Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

No next page URL returned from Bitbucket/Pipelines API in spite of large data set.

Matthew Bridges November 19, 2017

Tl;dr this started off as a request for help, but i've figured out how to get hold of the data, I think there's a bug with the next param on the API response.

I'm having difficulty iterating over the data returned from GET `/2.0/repositories/{username}/{repo_slug}/pipelines/` as the 'next' parameter used to call subsequent pages of the paginated data is returning None.

print(res.next)
None

data = res.json()

data.keys()
dict_keys(['values', 'pagelen', 'size', 'page'])

len(data['values'])
10


data['size']
189

print(data['values'][0])
{'completed_on': '2016-06-01T16:36:37.715Z', 'repository': {'type': 'repository', 'full_name': 'redacted', 'uuid': '{4cd38c15-a83c-4c99-bbe5-b38e446e2ac6}', 'name': 'redacted', 'links': {'self': {'href': 'https://api.bitbucket.org/2.0/repositories/user/repo'}, 'html': {'href': 'https://bitbucket.org/user/repo'}, 'avatar': {'href': 'https://bitbucket.org/user/repo/avatar/32/'}}}, 'state': {'type': 'pipeline_state_completed', 'result': {'type': 'pipeline_state_completed_failed', 'name': 'FAILED'}, 'name': 'COMPLETED'}, 'trigger': {'type': 'pipeline_trigger_push', 'name': 'PUSH'}, 'created_on': '2016-06-01T16:36:20.847Z', 'uuid': '{539bcae7-e9a4-43ce-b19d-507fae002e4c}', 'build_seconds_used': 10, 'target': {'ref_name': 'master', 'selector': {'type': 'default'}, 'commit': {'type': 'commit', 'hash': '7fae9efeac7d94139535603d6477821eac7d69f4', 'links': {'self': {'href': 'https://api.bitbucket.org/2.0/repositories/user/repo/commit/7fae9efeac7d94139535603d6477821eac7d69f4'}, 'html': {'href': 'https://bitbucket.org/user/repo/commits/7fae9efeac7d94139535603d6477821eac7d69f4'}}}, 'ref_type': 'branch', 'type': 'pipeline_ref_target'}, 'type': 'pipeline', 'creator': {'type': 'user', 'uuid': '{09a7942a-9f11-4e29-835b-6091b49ee6f2}', 'username': 'user', 'links': {'self': {'href': 'https://api.bitbucket.org/2.0/users/user'}, 'html': {'href': 'https://bitbucket.org/user/'}, 'avatar': {'href': 'https://bitbucket.org/account/user/avatar/32/'}}, 'display_name': 'User'}, 'build_number': 1}


 

Update:
I have been able to access the data by dividing the data['size'] by pagelen, and then making subsequent requests by building up the URL string manually.

 

Also, are there any parameters I can pass to the request in order to sort the data by completed on date?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events