Curling raw file fails

as I documented here: https://gitlab.com/gitlab-org/gitlab-ce/issues/61604 curling for a raw document fails. in my view this is a bug but my issue got closed without argument and I was directed here

can anyone help?

Hello @ekkis, welcome to forum.

Can you try with url api?

curl …

https://gitlab.com/api/v4/projects/:id/repository/archive.zip -o test.tar.gz

if I interpret you correctly I need curl -L --header "PRIVATE-TOKEN: UhGRPnvnEryPc499SQNZ" https://gitlab.com/api/v4/projects/capital-hero-deployment/scripts/raw/master/install but that fails with a 404

can you provide me with the exact command I should execute? the url I use with the browser to pull what I need is: https://gitlab.com/capital-hero-deployment/scripts/raw/master/install

Hi @ekkis and welcome to the forum.

If you’re curling a single raw file from a private repository via the API, you’ll need the project ID.

You can get this easily by viewing the project page:
**image **

To make your existing command work, replace the [VARIABLES] and it should work:

curl --header "PRIVATE-TOKEN: [PRIVATE_TOKEN]" https://gitlab.com/api/v4/projects/[PROJECT#]/repository/files/[RELATIVE_FILEPATH]/raw?ref=master

To download the file, you’ll need to add an additional -o [FILENAME] to the end of the curl command.

For example, to download a README.md file from the root directory a private repository with a Project # of 11:

curl --header "PRIVATE-TOKEN: [PRIVATE_TOKEN]" https://gitlab.com/api/v4/projects/11/repository/files/README.md/raw?ref=master -o README.md

All the best,
Greg

3 Likes

thanks Greg. your solutions works though I must say the experience leaves much to be desired vis-à-vis Github where I can take the same url as in my browser and hand it to curl

from an automation perspective I now need to figure out how to get the project ID and really why should I have to bother? I should be able to just use the project name. who the hell designs this stuff?

1 Like

Yeah this really slows down builds and it makes debugging a huge issue