【发布时间】:2022-01-20 15:31:03
【问题描述】:
我正在尝试通过 azure API 将文件推送到 git repo,但出现 activity_id 错误。我关注了他们的documentation 并尝试在我的存储库中添加简单文件。 这是我的代码:
import requests, base64
pat_token = "xxxx-xxxxx-xxxx"
b64Val = base64.b64encode(pat_token.encode()).decode()
payload = {
"refUpdates": [
{
"name": "refs/heads/main",
"oldObjectId": "505aae1f15ae153b7fc53e8bdb79ac997caa99e6"
}
],
"commits": [
{
"comment": "Added task markdown file.",
"changes": [
{
"changeType": "add",
"item": {
"path": "TimeStamps.txt"
},
"newContent": {
"content": "# Tasks\n\n* Item 1\n* Item 2",
"contentType": "rawtext"
}
}
]
}
]
}
headers = {
'Authorization': 'Basic %s' % b64Val,
'Content-Type': 'application/json',
}
params = (
('api-version', '6.0'),
)
response = requests.post('https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repo}/pushes', headers=headers, data=payload, params=params)
有人知道如何解决这个问题吗?我还在他们的开发者社区中添加了这个issue
【问题讨论】:
标签: python django azure-devops azure-devops-rest-api