I am able to achieve this with GitHub. But I am unable to do the same with GitLab. Currently, what I have is:
curl -u "$user:$token" -H "Content-Type:application/json" -H "PRIVATE-TOKEN:$token" \
-X DELETE https://git.lab.com/api/v4/projects/$repo_name
And then I get this error:
curl: (35) error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error
I already have a working script using curl to create a GitLab repository on the command line so my curl is working fine. I just needed the delete part.
On the top bar, select Menu > Projects and find your project. On the left sidebar, select Settings > General. Expand Advanced. In the "Permanently delete project" section, select Delete project.
Browse to the directory in your repository that you want to delete. In the top-right corner, click , then click Delete directory. Review the files you will delete. At the bottom of the page, type a short, meaningful commit message that describes the change you made to the file.
curl -H 'Content-Type: application/json' -H 'Private-Token: $privatetoken' \
-X DELETE https://gitlab.com/api/v4/projects/$namespace%2F$projectname
The URI is split by the forward slashes on the server side and then the resulting path elements are categorized.
Since the forward slash is treated as a special character, we need to URL encode it if we want to include it as a URI path element, so the server does not try to split it.
How this could cause a problem is more evident if you are executing a request with additional parameters behind the ID.
In the following examples $namespace
is foo
and $projectname
is bar
.
Good
Request: GET /projects/foo%2Fbar/users
URI path elements:
projects
- the resources the call will be executed onfoo%2Fbar
- the specific resource (project) name is foo/bar
(after URL decoding it)users
- the resources to returnBad
Request: GET /projects/foo/bar/users
URI path elements:
projects
- the resources the call will be executed onfoo
- the specific resource (project) name is foo
(no such project, namespace is missing)bar
- the resource to query or action to execute (no such resource or action)users
- additional query parameter (parent resource or action does not exist in the first place)If you are using the public GitLab hosted at https://gitlab.com/, you should use the gitlab.com
domain name instead of git.lab.com
, the latter is not owned by GitLab Inc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With