0

I have the following GitLab structure

Project-X
   - Repository-1
        - FileFoder-A
             - File-1
             - File-2
        - File-3
   - Repository-2
        - FileFoder-B
             - File-1
             - File-2
        - File-3

I am trying to fetch all files under Project-X/Repository-A using GitLab API v4.

I have tried the following:

https://gitlab.xx.local/api/v4/<project-x-id>/repository/<repository-A-id>/archive

But, it returns a 404.

RPT
  • 728
  • 1
  • 10
  • 29
  • `Project-X` is a group ? Also, you specify `archive` in your request but there is no file named `archive` in your repository. Ref il also missing. – Nicolas Pepinster Jul 22 '19 at 14:41
  • @NicolasPepinster, Project-X is a project in a group. I believe the archive was to retrieve the contents in tgz format. I tried with ref=master. But still the same result. – RPT Jul 22 '19 at 14:55
  • @NicolasPepinster even without the archive, it returns 404 – RPT Jul 22 '19 at 15:20

1 Answers1

1

There seems to be some confusion with the project structure. GitLab has a one to one relationship between projects and repositories. It's not possible that 'Project-X' has two repositories. Maybe you have a group with multiple projects?

In any case, the API endpoint is not quite right, either. It should be something like https://gitlab.xx.local/api/v4/projects/<project-x-id>/archive. See GitLab API documentation for the repository file archive endpoint for more details.

Drew Blessing
  • 2,595
  • 11
  • 16
  • 1
    When i do an `api/v4/projects//tree`, I can see all the directories under this project. But how can I get all the files of a specific directory under this project? – RPT Jul 22 '19 at 20:10
  • Is there any difference between a repo and a directory in Git? I can see from https://docs.gitlab.com/ee/api/repositories.html#get-file-archive - `Get a list of repository files and directories in a project.` – RPT Jul 22 '19 at 20:12
  • Files and directories are *in* a Git repository. – Drew Blessing Jul 24 '19 at 15:04