4

I have a GitLab project which is set up as follows:

  • myserver.com/SuperGroup/SubGroup/SubGroupProject

The tree of the following project is a top-level txt file and a txt file within a directory. I get the tree from the GitLab API with:

  • myserver.com/api/v4/projects/1/repository/tree?recursive=true

[{"id":"aba61143388f605d3fe9de9033ecb4575e4d9b69","name":"myDirectory","type":"tree","path":"myDirectory","mode":"040000"},{"id":"0e3a2b246ab92abac101d0eb2e96b57e2d24915d","name":"1stLevelFile.txt","type":"blob","path":"myDirectory/1stLevelFile.txt","mode":"100644"},{"id":"3501682ba833c3e50addab55e42488e98200b323","name":"top_level.txt","type":"blob","path":"top_level.txt","mode":"100644"}]

If I request the contents for top_level.txt they are returned without any issue via:

  • myserver.com/api/v4/projects/1/repository/files/top_level.txt?ref=master

However I am unable to access myDirectory/1stLevelFile.txt with any API call I try. E.g.:

  • myserver.com/api/v4/projects/1/repository/files/"myDirectory%2F1stLevelFile.txt"?ref=master and,
  • myserver.com/api/v4/projects/1/repository/files/"myDirectory%2F1stLevelFile%2Etxt"?ref=master

Results in:

Not Found The requested URL /api/v4/projects/1/repository/files/myDirectory/1stLevelFile.txt was not found on this server. Apache/2.4.25 (Debian) Server at myserver.com Port 443


  • myserver.com/api/v4/projects/1/repository/files/"myDirectory/1stLevelFile.txt"?ref=master and,
  • myserver.com/api/v4/projects/1/repository/files?ref=master&path=myDirectory%2F1stLevelFile.txt

Results in:

error "404 Not Found"

The versions of the components are:

GitLab 10.6.3-ee
GitLab Shell 6.0.4
GitLab Workhorse v4.0.0
GitLab API v4
Ruby 2.3.6p384
Rails 4.2.10
postgresql 9.6.8

According to my research there was a similar bug which was fixed with the 10.0.0 update.

I also added my ssh-key although I doubt it has any effect, following this advice with the same issue in php.

Solution: I eventually solved it by adjusting the apache installed on the server. Just follow these instructions: https://gitlab.com/gitlab-org/gitlab-ce/issues/35079#note_76374269

N.A.
  • 41
  • 6

1 Answers1

3

According to your code, I will go thinking you use curl.

If it is the case, why are you adding double quotes to your file path ? The doc do not contains it.

Can you test it like that please ? curl --request GET --header 'PRIVATE-TOKEN: XXXXXXXXX' myserver.com/api/v4/projects/1/repository/files/myDirectory%2F1stLevelFile%2Etxt?ref=master

Fanie Void
  • 331
  • 1
  • 9