Alt Text
Alt Text

How to curl single file using access token in gitlab

CloudOpz

Vu Dao
Jan 24, 2021

--

What鈥檚 In This Document

馃殌 Create access token

  • Go to User Setttings -> Access Tokens
Alt Text
Alt Text
Alt Text
Alt Text

馃殌 Get project ID to call API

Alt Text
Alt Text

馃殌 Get raw file from repository

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

  • Format: GET /projects/:id/repository/files/:file_path/raw
  • eg. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb/raw?ref=master"
  • To get file scripts/run.sh in project the url is
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/13083/repository/files/scripts%2Frun.sh/raw?ref=master"

Visit wwww.cloudopz.co to get more

馃尃 BlogWebLinkedinGroupPageTwitter 馃尃

--

--