I am developing a project using Nodejs
, as per the requirement I would like to list the files
present within the subfolder
of the GitLab repository
using the GitLab API
.
The subfolder contains many files so I would like to list all the file names and then traverse over the files one by one to read their content.
I am unable to list all the files present within a subfolder. However, I am able to read the contents of the specific file by providing the specific file name.
Following is the folder structure that I have within my GitLab repository:
projectName
- .FirstSubFolder
- SecondSubFolder
- ThirdSubFolder
Following is the API that I am trying which I would like to read all files within my ThirdSubFolder
:
https://{gitlabURL}/api/v4/projects/{id}/repository/files/%2EFirstSubFolder%2FSecondSubFolder%2FThirdSubFolder?ref=master&private_token={api}
This returns me:
{
"message": "404 File Not Found"
}
However, if I try to read the specific file within ThirdSubFolder
then I am able to get the contents:
https://{gitlabURL}/api/v4/projects/{id}/repository/files/%2EFirstSubFolder%2FSecondSubFolder%2FThirdSubFolder%2FmyFile.feature/raw?ref=master&private_token={api}
Can someone please assist me in how to read all the files present within the subfolder of the GitLab repository using the API?