GitLab API PATCH更新protected_branch权限返回200但数据未变更
GitLab受保护分支权限更新失败问题
无法更新GitLab中受保护分支的访问控制权限。调用API发送PATCH请求时返回状态码200,但实际权限数据并未更新。已尝试通过Postman、CURL及Python三种方式操作。
Python代码示例
import requests import json url = "http://<gitlab-url>/api/v4/projects/8/protected_branches/main?private_token=<api-token" payload = json.dumps({ "allowed_to_push": [ { "id": 8, "access_level": 30 } ], "allowed_to_merge": [ { "id": 8, "access_level": 0 } ] }) headers = { 'Content-Type': 'application/json', 'Cookie': 'preferred_language=en' } response = requests.request("PATCH", url, headers=headers, data=payload) print(response.text)
API返回结果
返回结果显示push_access_levels和merge_access_levels的access_level均未发生变化:
{ "id": 8, "name": "main", "push_access_levels": [ { "id": 8, "access_level": 40, "access_level_description": "Maintainers" } ], "merge_access_levels": [ { "id": 8, "access_level": 40, "access_level_description": "Maintainers" } ], "allow_force_push": false }
已严格遵循GitLab API文档中「更新推送访问权限记录」的示例操作。
内容的提问来源于stack exchange,提问作者Eric27710
相关产品推荐
相关产品推荐

