首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BitBucket Rest,更改存储库设置

BitBucket Rest,更改存储库设置
EN

Stack Overflow用户
提问于 2022-09-12 07:40:02
回答 1查看 269关注 0票数 0

所以我有了这个repo:https://bitbucket.com/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/这个URL输出了很多关于存储库的信息

然后,我尝试创建一个Python脚本,该脚本专门处理以下URL信息:

代码语言:javascript
复制
import requests

headers = {
    'Content-Type': 'application/json',
}

response = requests.get('https://bitbucket.com/rest/api/1.0/projects/GGT/repos/GRP1/', headers=headers, auth=('USERNAME', 'TOKEN'))
print(response.text)

这将打印出相同的JSON内容,如图所示。

现在我知道我有一个到存储库的连接。然后,我想在这个回购中添加一个Web钩子,但我似乎找不出如何做到这一点。

我试着做这样的事,但那行不通。

代码语言:javascript
复制
json_data = {
    'title': 'BitBucket_Webhook',
    'url': 'http://uua231z:5000/bitbucket',
    'enabled': 'true',
}

response = requests.put('https://bitbucket.com/rest/webhook/1.0/projects/GGT/repos/GRP1/configurations', headers=headers, json=json_data, auth=('USERNAME', 'TOKEN'))
print(response)

我怎么能添加一个网络钩子到一个存储库,似乎找不到那么多在互联网上,这是如何可能的?

--我从评论中尝试了这一点

代码语言:javascript
复制
headers = {
    # Already added when you pass json= but not when you pass data=
    # 'Content-Type': 'application/json',
}

json_data = {
    'title': 'BitBucket_Webhook2',
    'url': 'http://test123:5000/bitbucket',
    'enabled': 'true',
}

# Found here: https://docs.atlassian.com/bitbucket-server/rest/4.1.0/bitbucket-rest.html
response = requests.put('https://bitbucket.com/rest/api/1.0/projects/GGT/repos/grp1/webhooks', headers=headers, json=json_data, auth=('USERNAME', 'TOKEN'))
print(response)

但我得到了<Response [405]>

EN

回答 1

Stack Overflow用户

发布于 2022-09-12 07:57:13

您可能想要查看官方的API文档以获得API。有一个HTTP (POST) /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks可以解决您的需求。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73685931

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档