forked from Lesin/reposync
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import urllib
|
||
import requests
|
||
|
||
owner = 'xumingyang21'
|
||
repo = 'reposyncer2'
|
||
id = '33264649'
|
||
# Gitee创建issue的API URL
|
||
url = f'https://gitee.com/api/v5/repos/{owner}/{repo}/issues/comments/{id}'
|
||
|
||
# 构造请求头
|
||
token = 'f2be2313581c1fde50b16bf35bb655c5'
|
||
headers = {'Authorization': f'token {token}'}
|
||
|
||
# 发送POST请求
|
||
data = {
|
||
"access_token": token,
|
||
"owner": owner,
|
||
"repo": repo,
|
||
"body" : '尝试更改评论'
|
||
}
|
||
# 将字典转换为查询字符串
|
||
query_string = urllib.parse.urlencode(data)
|
||
|
||
# 完整的请求 URL,包括查询字符串
|
||
full_url1 = f"{url}?{query_string}"
|
||
response = requests.patch(full_url1, headers=headers, json=data)
|
||
# 打印响应
|
||
print(response.text)
|
||
# 检查响应状态码
|
||
if response.status_code == 200:
|
||
# 注意:这里假设响应体中包含一个'number'字段作为issue的ID,但实际上Gitee可能返回不同的结构
|
||
# 你需要根据实际的响应结构来调整以下代码
|
||
issue_info = response.json()
|
||
else:
|
||
print(f"创建issue失败,状态码:{response.status_code},错误信息:{response.text}")
|
||
|
||
|