Use file_path parameter instead of url encoding in repository files api
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=20955) </details> <!--IssueSummary end--> ### Description Seems like there has been some confusion, problems with url encoding when using the repository files api. Getting files require url encoding which is harder/confusing with files within subfolders. For example from the [api](https://docs.gitlab.com/ee/api/repository_files.html#get-raw-file-from-repository) docs: ``` file_path (required) - Url encoded full path to new file. Ex. lib%2Fclass%2Erb ``` ### Proposal Update existing, or add additional endpoint that doesn't use the file as part of request endpoint. https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/api/files.rb#L63 For example, I tested adding this: ``` desc 'Get raw file contents from the repository' params do requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb' requires :ref, type: String, desc: 'The name of branch, tag commit' end get ":id/repository/files/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do assign_file_vars! send_git_blob @repo, @blob end ``` Couple example requests with this vs current url encoding. ``` curl --request GET --header $TOKEN "http://$URI/api/v4/projects/13/repository/files/raw?ref=master&file_path=directory/test.rb" curl --request GET --header $TOKEN "http://$URI/api/v4/projects/13/repository/files/directory%2Ftest%2Erb/raw?ref=master" ``` ``` import requests url = "http://gitlab/api/v4/projects/13/repository/files/raw" payload = {'file_path': 'directory/test.rb', 'ref': 'master'} r = requests.get(url,headers=headers, params=payload) print r.text url = "http://gitlab/api/v4/projects/13/repository/files/directory%2Ftest%2Erb/raw" payload = {'ref': 'master'} r = requests.get(url,headers=headers, params=payload) print r.text ``` ### Links / references Internal Zendesk: https://gitlab.zendesk.com/agent/tickets/90060
issue