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

bitbucket api errors out when listing total repos in a project using python function

Prasoon Majumdar May 8, 2018

I am using the below python function for getting total number of repos in a project

def new_slug_test():
req = requests.get(GITBASEURL + "/projects/" +
'G4FLIGHTWS' + "/repos", headers=BITBUCKETHEADERS)
NEW_SLUG_LIST = []
while True:
for slugs in req.json()['values']:
try:
print(slugs['slug'])
NEW_SLUG_LIST.append(slugs['slug'])
except ValueError:
print("Oops")
if req.json()['isLastPage']:
break
else:
print("hello , its not the last page")
req = requests.get(GITBASEURL + "/projects" +
'G4FLIGHTWS' + "/repos" + "?start=" +
str(req.json()['nextPageStart']), headers=BITBUCKETHEADERS)


Indentations got screwed here bcz of formatting, but this is the exact function i am using to get the complete list of repos which is more than 25 , but looks like its just not going beyong 25 items or the next page and errors out like below :

 

g4-checkinboard-bso
g4-checkinboard-bso-client
g4-flight-ancillary-bso
g4-flight-ancillary-bso-client
g4-flight-base
g4-flight-common
g4-flight-common-client
g4-flight-custcoms
g4-flight-disposition
g4-flight-disposition-bso
g4-flight-disposition-orch
g4-flight-fare
g4-flight-fares-bso
g4-flight-fares-bso-client
g4-flight-inventory
g4-flight-management-bso
g4-flight-management-bso-client
g4-flight-order-bso
g4-flight-order-bso-client
g4-flight-payment
g4-flight-record
g4-flight-report-bso
g4-flight-reservation
g4-flight-schedules
g4-flight-schedules-bso
hello , its not the last page
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in new_slug_test
File "/home/em7b/.local/lib/python3.5/site-packages/requests/models.py", line 884, in json
self.content.decode(encoding), **kwargs
File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

 

I would like this to be fixed or if there is any other way ?

 

1 answer

0 votes
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 28, 2021

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events