DEV Community

Cover image for How To Curl Single File Using Access Token In Gitlab
๐Ÿš€ Vu Dao ๐Ÿš€
๐Ÿš€ Vu Dao ๐Ÿš€

Posted on โ€ข Edited on

8 2

How To Curl Single File Using Access Token In Gitlab

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: " "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
Enter fullscreen mode Exit fullscreen mode

curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/13083/repository/files/scripts%2Frun.sh/raw?ref=master"


<h3 align="center">
  <a href="https://dev.to/vumdao">:stars: Blog</a>
  <span> ยท </span>
  <a href="https://vumdao.hashnode.dev/">Web</a>
  <span> ยท </span>
  <a href="https://www.linkedin.com/in/vu-dao-9280ab43/">Linkedin</a>
  <span> ยท </span>
  <a href="https://www.linkedin.com/groups/12488649/">Group</a>
  <span> ยท </span>
  <a href="https://www.facebook.com/CloudOpz-104917804863956">Page</a>
  <span> ยท </span>
  <a href="https://twitter.com/VuDao81124667">Twitter :stars:</a>
</h3>

Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where youโ€™ll build it, break it, debug it, and fix it. Youโ€™ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good olโ€™ AI to find and fix issues fast.

RSVP here โ†’

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs