Today was short and sweet
I figured out what I did wrong yesterday – when you wanna get a file inside a subdirectory in GitLab you need to use the API like this
GET /projects/:id/repository/files/:file_path
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb?ref=main"
if you look closely you can notice that the “file path” is not described using slashes but URL-encoded
that was my problem – I tried to access the URL like this
https://gitlab.example.com/api/v4/projects/13083/repository/files/app/models/key.rb?ref=main
but I should have done it like this
- get path /app/modules/key.rb
this -> app/models/key.rb
turns into
this -> app%2Fmodels%2Fkey.rb (url encoded) - put it into a URL encoder https://www.urlencoder.org/
- create the request -> append ?ref=main (if you wanna get the main branch version of the file)
https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey.rb?ref=main
then I continued to spike a prototype for another Python program today and got off work at noon <3
That is about it for today 😀 it is a short log but it contains a deep insight – had I PROPERLY read the docs I would have cut down my pain yesterday by approximately 4-6 hours
See ya in the next post <3