DEV Community

loading...
Cover image for How To Curl Single File Using Access Token In Gitlab

How To Curl Single File Using Access Token In Gitlab

vumdao profile image Vu Dao Updated on ・1 min read

What’s In This Document

🚀 Create access token

  • Go to User Setttings -> Access Tokens

Alt Text

Alt Text

🚀 Get project ID to call API

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

  • Example

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb/raw?ref=master"
Enter fullscreen mode Exit fullscreen mode
  • 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"
Enter fullscreen mode Exit fullscreen mode

🌠 Blog · Web · Linkedin · Group · Page · Twitter 🌠

Discussion (0)

pic
Editor guide