Cannot pass multiple query string paramters to GitLab API

I have run into the following issue when using the GitLab API (v4) for a GET tree request:

When attempting to use multiple query string parameters, only the first one gets processed. So for example if I say

curl --request GET --header 'PRIVATE-TOKEN: ${token}' https://my.self.hosted.gitlab/api/v4/projects/${myProject}/repository/tree?ref=mybranch&path=root/sub/sub

it successfully looks into mybranch, but path=root/sub/sub is ignored and only the results for the root directory are returned

1 Like

I am having the same trouble with multiple parameters here, using Gitlab Community Edition [11.4.9].
I need to access a raw file, just by providing an URI string. Theoretically it could be possible, using a query string with two parameters : ref and private_token, but apparently only the first query parameter is supported :

If I put the private_token first, eg:

curl https://mygitlab.domain/api/v4/projects/<project>/repository/files/<path>/raw?private_token=<token>&ref=master

I get :

{"error":"ref is missing, ref is empty"}

If I put the ref=master first, eg:

curl https://mygitlab.domain/api/v4/projects/<project>/repository/files/<path>/raw?ref=master&private_token=<token>

I get:

{"message":"404 Project Not Found"}

Only if I put the token into a HTTP header :

curl  --header 'PRIVATE-TOKEN: <token>' https://mygitlab.domain/api/v4/projects/<project>/repository/files/<path>/raw?ref=master

It works. But this is not acceptable because I can only provide a simple string URI (here I only use curl for debugging purpose).

Using a previous Gitlab version, before my sysadmin upgraded it, it was possible to have a URI like :


And it was working fine, but now this syntax seems not to be supported anymore, and I cannot find any working alternatives.

Any help would be greatly appreciated.


I have a similar problem but with other paramters.
For instance, when trying the given example (see, the second paramater is not recognized

curl --request GET --header "PRIVATE-TOKEN: <your_access_token>"**&**state=opened
Only first paramater is taken into account (labels=AAA), and for the second one (state=opened), I get the error message:
‘state’ is not recognized as an internal or external command,operable program or batch file.
Is there a way to use multiple criteria in a request ?
maybe I missed something by using the API.
Thanks in advance for your support !

You need double quotes (") around any url with an &. So your curl request needs to be:

curl --request GET --header "PRIVATE-TOKEN: ${token}" "https://my.self.hosted.gitlab/api/v4/projects/${myProject}/repository/tree?ref=mybranch&path=root/sub/sub"

Also note correction to --header quotes to interpolate the token variable.