title: GitLab API - Unable to access file which is within a directory
body: <p>I have a GitLab project which is set up as follows:</p>
  
  <ul>
  <li><code>myserver.com/SuperGroup/SubGroup/SubGroupProject</code></li>
  </ul>
  
  <p>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:</p>
  
  <ul>
  <li><code>myserver.com/api/v4/projects/1/repository/tree?recursive=true</code></li>
  </ul>
  
  <blockquote>
    <p>[{"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"}]</p>
  </blockquote>
  
  <p>If I request the contents for <code>top_level.txt</code> they are returned without any issue via:</p>
  
  <ul>
  <li><code>myserver.com/api/v4/projects/1/repository/files/top_level.txt?ref=master</code></li>
  </ul>
  
  <hr>
  
  <p>However I am unable to access <code>myDirectory/1stLevelFile.txt</code> with any API call I try. E.g.:</p>
  
  <ul>
  <li><code>myserver.com/api/v4/projects/1/repository/files/"myDirectory%2F1stLevelFile.txt"?ref=master</code> 
  and,</li>
  <li><code>myserver.com/api/v4/projects/1/repository/files/"myDirectory%2F1stLevelFile%2Etxt"?ref=master</code></li>
  </ul>
  
  <p>Results in:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <hr>
  
  <ul>
  <li><code>myserver.com/api/v4/projects/1/repository/files/"myDirectory/1stLevelFile.txt"?ref=master</code> and,</li>
  <li><code>myserver.com/api/v4/projects/1/repository/files?ref=master&amp;path=myDirectory%2F1stLevelFile.txt</code></li>
  </ul>
  
  <p>Results in:</p>
  
  <blockquote>
    <p>error "404 Not Found"</p>
  </blockquote>
  
  <p>The versions of the components are:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>According to my research there was a similar bug which was fixed with the 10.0.0 update.</p>
  
  <p>I also added my ssh-key although I doubt it has any effect, following this advice with the same <a href="https://forum.gitlab.com/t/solved-api-list-repositories-access-subdirectory-not-working-using-curl/2966/2" rel="nofollow noreferrer">issue in php</a>.</p>
  
  <p><strong>Solution:</strong>
  I eventually solved it by adjusting the apache installed on the server.
  Just follow these instructions: <a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/35079#note_76374269" rel="nofollow noreferrer">https://gitlab.com/gitlab-org/gitlab-ce/issues/35079#note_76374269</a></p>