I am trying to get a single branch in Postman using info from:
When the branch name is single word like ‘master’ the GET operation returns correctly the branch info.
For example something like “https://gitlab.example.com/api/v4/projects/5/repository/branches/master” works fine.
But when the name of branch contains slashes like ‘my/test/master’:
the response is:
“error”: “404 Not Found”
How should I write the name of the branch in order to get the proper response?
I think you should do “percent encoding” to the branch name.
Every programming language has something like “URL encoder/decoder”, e.g. Python3 has
generically, refer to RFC 3986
If your branch name is
Put it into url encoding lib, and it will become:
Whatever language you are using to interact with gitlab API, if it has http client, it has a url encoding ability.
You can try this online:
I tried “https://gitlab.example.com/api/v4/projects/5/repository/branches/my%2Ftest%2Fmaster” and it worked ok -in Powershell and in Postman also.
Thanks a lot for your help!
great news, pls mark the question answered