简体   繁体   中英

How to get all of my Issues in my Bitbucket repository using the API

I am using Java and made a get Request via Unirest.get (see the code below).

The code works fine, but I have one big problem: I do not get all of my Issues, only 20 of them.

Can you please tell me why I don't get all of them?

String json = new Gson().toJson(Unirest.get("https://api.bitbucket.org/2.0/repositories/{username}/{repo_slug}/issues")
            .header("Authorization", "Basic " + encoded)
            .header("Content-Type", "application/json; charset=UTF-8")
            .header("Accept", "application/json; charset=UTF-8")
            .asJson());
System.out.println(json);

When I copy the output in a .json file I don't get all of my Issues as I expected.

The docs state that there's a parameter pagelen which has this description:

Current number of objects on the existing page. The default value is 10 with 100 being the maximum allowed value. Individual APIs may enforce different values.

So it seems like there's pagination going on, you can either set this pagelen to be larger, or you can get the next property which is a URI to the next page of objects and load the remaining objects that way.

Example url with pagelen of 100 inspired by this :

https://api.bitbucket.org/2.0/repositories/{username}/{repo_slug}/issues?pagelen=100

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM