How to get with API a branch name containing slashes

Hi
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’:
https://gitlab.example.com/api/v4/projects/5/repository/branches/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 urllib.parse.quote_plus()

generically, refer to RFC 3986

I tried with “https://gitlab.example.com/api/v4/projects/5/repository/branches/%my/test/master%” but the response was:
400 Bad Request

Hi.
If your branch name is my/branch,
Put it into url encoding lib, and it will become: my%2Fbranch

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 :pray: