gitlab api学习笔记

gitlab api学习笔记

Most API requests require authentication, or only return public data when authentication isn’t provided. When authentication is not required, the documentation for each endpoint specifies this. For example, the /projects/:id endpoint does not require authentication.

curl --request POST --header "Content-Type: application/json" --data '{ "name": "new_project", "description": "New Project", "path": "new_project", "namespace_id": "42", "initialize_with_readme": "true"}'  --url 'https://jihulab.com/course-test-group/new_project'
curl --request POST --header "PRIVATE-TOKEN: 9UxYzs7Gi8apx6M-dsuY" --header "Content-Type: application/json" --data "{ \"name\": \"new_project3\", \"description\": \"New Project\", \"path\": \"course-test-group\", \"namespace\": \"Jalon\", \"initialize_with_readme\": \"true\"}" --url "https://jihulab.com/api/v4/groups/94371"
curl --request POST --header "PRIVATE-TOKEN: 9UxYzs7Gi8apx6M-dsuY" --header "Content-Type: application/json" --data "{ \"name\": \"new_project3\", \"description\": \"New Project\", \"path\": \"course-test-group\", \"namespace\": \"Jalon\", \"initialize_with_readme\": \"true\"}" --url "https://jihulab.com/api/v4/projects/"

可用:
curl --request POST --header "PRIVATE-TOKEN: 9UxYzs7Gi8apx6M-dsuY" --header "Content-Type: application/json" --data "{ \"name\": \"new_project3\", \"description\": \"New Project\", \"path\": \"course-test-group\", \"namespace\": \"42\", \"initialize_with_readme\": \"true\"}" --url "https://jihulab.com/api/v4/projects/"


404
curl --request POST --header "PRIVATE-TOKEN: 9UxYzs7Gi8apx6M-dsuY" --header "Content-Type: application/json" --data "{ \"name\": \"new_project3\", \"description\": \"New Project\", \"namespace\": \"Jalon\", \"initialize_with_readme\": \"true\"}" --url "https://jihulab.com/api/v4/groups/94371/projects/"

curl --request POST --header "PRIVATE-TOKEN: 9UxYzs7Gi8apx6M-dsuY"  --header "Content-Type: application/json" "https://jihulab.com/api/v4/groups/94371/projects/57287"


创建群组(可用):
curl --request POST --header "PRIVATE-TOKEN: 9UxYzs7Gi8apx6M-dsuY" --header "Content-Type: application/json" --data "{ \"name\": \"new_project_7\", \"description\": \"New Project\", \"path\": \"course-test-group2\", \"namespace\": \"course-test-group\", \"initialize_with_readme\": \"true\"}" --url "https://jihulab.com/api/v4/groups/"


在组中加入项目(可用):
curl --request POST --header "PRIVATE-TOKEN: mA-yysNcjPbxuTkAkWVx" --header "Content-Type: application/json" --data "{ \"name\": \"new_project9\", \"description\": \"New Project\", \"path\": \"test_path\", \"namespace_id\": \"94371\", \"initialize_with_readme\": \"true\"}" --url "https://jihulab.com/api/v4/projects/"

v3已经被遗弃不用了
namespace_id可以决定项目在哪个群组里
但是用namespace就不行,只会在自己名下创建项目
POST请求返回:401 Unauthorized,是因为密钥有误

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注