You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法通过GitLab API设置项目共享组,请求返回404错误

GitLab API共享项目至群组返回404 Not Found问题

我创建了GitLab群组Team A,想把它邀请到项目Project A里。通过UI操作能成功实现,但用GitLab API执行时,请求返回{"message": "Not Found"}错误。我可以用DELETE请求的API移除通过UI添加的共享群组,但就是没法通过API创建共享关系,是不是漏了什么配置?

参考文档

我参考的是GitLab 14.10版本EE版文档中「共享项目给群组」的相关内容

使用的curl命令

curl --request POST --url "https://<gitlab url>/api/v4/projects/<project id>/share" \
  -H "PRIVATE-TOKEN: <redacted>" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "@/tmp/payload.json"

请求负载内容

{
    "group_id": 3523, 
    "group_access": 30
}

GitLab版本信息

GitLab Enterprise Edition 14.10.4-ee

详细curl请求输出

* Connected to gitlab  port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  start date: Jul 20 00:00:00 2023 GMT
*  expire date: Aug 17 23:59:59 2024 GMT
*  SSL certificate verify ok.
* using HTTP/1.x
> POST /api/v4/projects/<id>/share HTTP/1.1
> Host: <gitlab url>
> User-Agent: curl/8.1.2
> PRIVATE-TOKEN: <redacted>
> Accept: application/json
> Content-Type: application/json
> Content-Length: 46
> 
< HTTP/1.1 404 Not Found
< Date: Sat, 14 Oct 2023 17:45:38 GMT
< Content-Type: application/json
< Content-Length: 23
< Connection: keep-alive
< Cache-Control: no-cache
< Vary: Origin
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-Request-Id: 01HCQMPC5JQ5GYJBW5C80NN9S4
< X-Runtime: 0.071873
< Strict-Transport-Security: max-age=15724800; includeSubDomains
< 
* Connection #0 to host <gitlab url> left intact
{"message":"Not Found"}%   

重要说明

我用的是正确且存在的项目ID——不然也没法通过API删除项目里的共享群组。搞不懂为什么创建共享关系时会返回404 Not Found,希望能得到解决办法。

UI操作成功截图

UI成功将项目共享给群组的截图


内容的提问来源于stack exchange,提问作者jlim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 07:30:08