Cannot find base URL of GitLab base API

I created a project and repo on my gitlab.com account, generated a private key, now I'm trying to make an API call to get a list of commits.

Now I want to get a list of projects through the API, from the documentation https://docs.gitlab.com/ce/api/projects.html#list-projects

GET /projects

So i do

curl --header "PRIVATE-TOKEN: XXXXXXX -c" "https://gitlab.com/projects"

And getting 404. I tried several combinations and cannot find the correct base URL.

The same for fixing the repository, the documentation https://docs.gitlab.com/ce/api/commits.html says

https://gitlab.example.com/api/v3/projects/5/repository/commits

ok i try (with myusername / projectname as project id) https://gitlab.com/api/v3/projects/myusername/projectname/repository/commits

And got 404 as well

+7
source share
3

url GitLab https://gitlab.com/api/v4/, GET /projects

curl --header "PRIVATE-TOKEN: XXXXXX" "https://gitlab.com/api/v4/projects"

, . GET /projects

+8

:

curl --header "PRIVATE-TOKEN: YOUR_TOKEN" "https://gitlab.com/api/v4/users/YOUR_USER_ID/projects" 

I don’t know why the request: curl --header "PRIVATE-TOKEN: PRIVATE_TOKEN" "https://gitlab.com/api/v4/projects/"returned a list with some other open projects.

Another useful user info request: curl --header "PRIVATE-TOKEN: PRIVATE_TOKEN" "https://gitlab.com/api/v4/user/"

0
source

Source: https://habr.com/ru/post/1656113/


All Articles