5

In the gitlab documentation, it specifies that the issues endpoint is only for the logged in user. The only other alternative is to iterate over all the projects and get them this way. We have an external scheduling engine, but we first need to be able to get every issue that has been created.

How do I either:

  • Access an endpoint which will get me all issues for all projects, preferably sorted by date order
  • Create an endpoint if one doesn't exist
Cetra
  • 2,593
  • 1
  • 21
  • 27

2 Answers2

2

In both cases (list project issues and list all projects), you need to use a GitLab private token from an admin account (see for instance "Gitlab API: How to generate the private token")

You need such an account to use the existing endpoints for listing all the resources you need.

But after that, you will still need two steps, one for getting the projects, one for the issues per projects, as there is no existing endpoint natively getting all issues per project in one call.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I am definitely an Admin, but as I didn't create any issues (someone else has) I am receiving a blank response from the issues API. The generic `issues` endpoint will only show tickets that you have created. I need an endpoint which will show me all tickets. – Cetra May 04 '16 at 03:02
  • @Cetra http://doc.gitlab.com/ce/api/issues.html#list-project-issues lists *all* issues. http://doc.gitlab.com/ce/api/issues.html#list-issues lists issues created by the authenticated users. – VonC May 04 '16 at 04:35
  • it lists all issues of a project, not globally. I have to manually iterate over all projects, and work out the ordering. I was hoping to decouple the issue from the project in other words – Cetra May 06 '16 at 05:47
  • @Cetra I agree: you need to iterate over all projects for listing all issues. – VonC May 06 '16 at 05:51
  • 1
    @VonC as mentioned on the link you shared: `By default, GET requests return 20 results at a time because the API results are paginated. Read more on [pagination](https://docs.gitlab.com/ce/api/README.html#pagination).` – Fr0zenFyr May 17 '18 at 07:53
  • @Fr0zenFyr Agreed, you need to take into account pagination. – VonC May 17 '18 at 08:00
0

The correct link is : https://docs.gitlab.com/ee/api/rest/index.html#pagination where the solution is :

curl --request GET --header "PRIVATE-TOKEN:mysecretkey" \
"https://gitlab.mydomain.ext/api/v4/projects/xx/issues?per_page=50"

For the 50 last issues... maybe then pipe with jq to have a structured json output. But it seems, for the repo i tested, the per_page is limited to 100...

HiroCereal
  • 550
  • 1
  • 11