4

In GitLab you can create subgroups within a group and projects within those subgroups. The GitLab documentation allows you to list the subgroups of a group and the projects of a group, but I cannot find anything about listing projects of a subgroup. Does anyone know the curl command for this, or at least know that it's not supported yet?

I've tried:
curl -s -H 'PRIVATE-TOKEN: xxxxx' https://gitlab.com/api/v4/groups/mygroup/subgroups/mysubgroup/projects
curl -s -H 'PRIVATE-TOKEN: xxxxx' https://gitlab.com/api/v4/subgroups/mysubgroup/projects
and other similar variations with no luck so far.

chacd
  • 81
  • 1
  • 3

4 Answers4

3

Use %2f to specify full path to subgroup:

curl -s https://gitlab.com/api/v4/groups/gitlab-org%2fgitter/projects

See this issue.

giraffes
  • 31
  • 2
2

To get all the projects of group and subgroups call the api like this

curl --silent --header "Private-Token: YOUR_GITLAB_TOKEN" https://gitlab.example.com/api/v4/groups/<group_name>/projects?include_subgroups=true

or using group id

<your_gitlab-url>/api/v4/groups/<group_ID>/projects?include_subgroups=true
Dashrath Mundkar
  • 3,376
  • 1
  • 13
  • 26
1

You should be able to list the projects of any group (subgroup or not) through said group ID:

See "List a group's projects"

GET /groups/:id/projects

So first get a list of the subgroups in order to get their IDs, then query their projects.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 1
    Thanks for the response. That works with the numerical id, but not the actual name of the group, but I will use that as a final resort. – chacd Aug 24 '18 at 10:13
0

To get all soubgrups of group call the v4 gitlab API like this

GET /groups/:id/subgroups