API | Get file from repository without Project ID

How Can I use the API to get a file from a repository without the Project ID?

  • In the API documentation I see that you can get a file from a repository if you have a project ID. Is there a way to get a file if you just have groups, sub-groups, and a project name and file path?

  • I am using Gitlab 13.7 EE, but I am interested in answers for any newer versions of EE as well.

  • Currently I am trying scripts to map and determine of the ID of all projects. If there is an easy way to do this even when there are sub-groups, let me know.

Hi @bobbaxter

You could search for a project by name for example:

https://gitlab.com/api/v4/projects?search=triage-ops

Or maybe iterate over the projects belonging to a group.

HTH,

Sarah

It is also possible to use the get project id using the get single project API

https://gitlab.com/api/v4/projects/encoded_name_and_reponame
Should look something like this
https://gitlab.com/api/v4/projects/jona62%2Fmy-repo

The response object will contain the project Id of the project in question and you can avoid iterating through search results.

{
  "id": 11121234,
  "description": null,
   ...
}