How using api gitlab to download file

EDIT:
I have tried this but it doesn’t work.

https://gitlab.xxxxxxxx/api/v4/projects/98/repository/files/src%2Fmain%2Fscript%2Fdeploiement%2Fsettings%2Frci%2Fsetting.sh?ref=master

Cannot understand how using api to download with curl my file on gitlab.

here my url:

https://gitlabxxxxxxx/administration/gitlab/raw/master/src/main/script/deploiement/settings/rci/setting.sh

I have checked official website but cannot understand how it’s works and which part I should replace:

curl --request GET --header 'PRIVATE-TOKEN: ’ ‘https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb/raw?ref=master

I have tried but it’s not working

curl --insecure --request GET --header ‘PRIVATE-TOKEN: Y_F8YP3nUnFbzhxkQvgo’ ‘https://gitlabxxxxxxxxxx/api/v4/administration/gitlab/98/src/main/script/deploiement/settings/rci/sesameweb2.sh/app%2Fmodels%2Fkey.rb/raw?ref=master

My project ID is : 98 I would like to download this setting.sh, I’am using gitlab-ce 12.6.4.

Thanks for help

I was able to download an archive of my code branch by using this command:

curl -k --header "PRIVATE-TOKEN: xxxx" https://gitlab.xxxxx/api/v4/projects/1389/repository/archive?sha=630bc911c1c20283d3980dcb95fd5cb75479bb9c -o myFilename.tar.gz

I got the SHA value from the webUI after selecting the branch I wanted from the pull-down and copying the value on the right for the SHA.

image

I hope that helps.

2 Likes

Thank you @frakman it helped me after 3-4 hours of trouble

1 Like