Extracting a single file from the repository: how to specify a branch?

I managed to use the instructions here to be able to fetch files individually from the repository

  https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository

How do I specify a given branch, though? I get the impression that

  ?ref=MAIN

will work in the simple case. But in my case the name of the branch is

  _ubuntu-pgi-openmpi.system/_Dockerfile

and I’ve tried things like

   ref=_ubuntu-pgi-openmpi.system/_Dockerfile
   ref=_ubuntu-pgi-openmpi.system/=%2F_Dockerfile

as well as “branch=…” but none of them have worked.

I also filed a request that the documentation use a working example, i.e. point to a real project in the repo so we can run the example verbatim and see that it works.

  https://gitlab.com/gitlab-org/gitlab/-/issues/463188

The solution here involves some encoding conventions plus user- and project- parameters, and it’s hard to get it all right just from following the templates.

1 Like