gitlab4j / gitlab4j-api

GitLab4J API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories via the GitLab REST API
MIT License
1.07k stars 459 forks source link

API access to IP/projectpath allows access, but accessing domain name/projectpath will return 404 error #990

Closed Qinghuand closed 1 year ago

Qinghuand commented 1 year ago

API访问IP/项目路径允许访问,但访问域名/项目路径将返回404错误 The reason is that when requesting a domain name, an/API/v4 will be added. After removing it, I can access it completely. What is the reason for this

jmini commented 1 year ago

Could you share some java code of what you are doing?

Qinghuand commented 1 year ago

OK GitLabApi gitLabApi = new GitLabApi(address, token); Project project = null; try { project = gitLabApi.getProjectApi().getProject("jnpf/wmm_oa/vue"); } catch (GitLabApiException e) { e.printStackTrace(); } return project; This is my code example When the address is the server IP, it can be executed normally But when address is a domain name address, for example: http://gitlab. . com will return 404 Through debugging, it was found that the actual address is http://gitlab. . com/api/v4/projects, which caused this issue to occur. After deleting/api/v4/projects from the visited address, I can access it normally Thank you for your help

jmini commented 1 year ago

I am not sure to understand your setup correctly:

If you have a GitLab server at https://gitlab.company.com then the REST API is available at https://gitlab.company.com/api/v4.

Your call:

gitLabApi.getProjectApi().getProject("jnpf/wmm_oa/vue")

Will execute a REST call:

GET <gitlab-server provided with address>/api/v4/projects/jnpf%2Fwmm%5Foa%2Fvue

See: https://docs.gitlab.com/ee/api/projects.html#get-single-project

Qinghuand commented 1 year ago

Okay, I'll give it a try