jaaq
August 22, 2019, 12:53pm
1
Hi, I’m trying to read a git file using api gitlab v4.If the file is in the first level, I get it without problems.
“https://nameGit/api/v4/projects/:projectId/repository/files/file1.json?ref=master ”
However, if the file is inside a folder, it is not possible:
“https://nameGit/api/v4/projects/:projectId/repository/files/filesFolder%2Ffile1.json?ref=master ”
Therefore, I think there is a problem with “file_path” for v4.
Thank you
I checked with a project of my own using: GitLab 12.1.6 (4016bcac51d)
curl --header "PRIVATE-TOKEN: *************" "https://git.***********.net/api/v4/projects/179/repository/files/README.md?ref=develop"
curl --header "PRIVATE-TOKEN: *************" "https://git.***********.net/api/v4/projects/179/repository/files/ci%2Fbuild.sh?ref=develop"
Both return a json object with file metadata.
If you get different results, I would assume you have a typo in the path of your second http call. Or if you are expecting the raw file you should add `/raw’ after the file name.
Best,
Jonathan
jaaq
August 28, 2019, 12:17pm
3
Thank you very much, I have checked what you say and I still see the same error
message “404 File Not Found”
Can it be because of the gitlab version? I am using 11.3.6