azure - 如何找到 Azure 拉取请求的 threadID?
问题描述
我正在尝试使用 Powershell 中的 Azure API 对 PR 发表评论。
我已经实现了它:
$postURL = "https://dev.azure.com/$organization/$project/_apis/git/repositories/$repositoryId/pullRequests/$pullRequestId/threads/$threadId/comments?api-version=5.0"
$prComment = Invoke-RestMethod -Uri $postURL -Headers @{Authorization = $pat} -Body $body
当我运行它时,$threadId = 1
我得到:
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"The requested> pull request comment thread '1' 找不到。
当我运行它时,$threadId = 0
我得到:
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"值 0 超出允许范围
这是 ID 为 1 的拉取请求的评论部分的图像:
那么什么是thread id
PR?
解决方案
我通过使用 API 发现:
https://dev.azure.com/$organization/$project/_apis/git/repositories/$repositoryId/pullRequests/$pullRequestId/threads?api-version=5.0
您可以获得该 PR 的线程列表。评论部分的每一行代表一个线程。我认为线程 id 与 PR 相关联(即,该 PRcreated by PB
内的线程 id 为 1),但事实并非如此。每个新线程都会增加线程 ID。因此,如果我在不同的 PR 中添加一个线程,它可能有线程 id 231
。如果我在不同的 PR 中添加另一个线程,它将具有 id 232
。这很烦人。我不明白为什么 Azure 会以这种方式实现它。
推荐阅读
- python - 从张量中提取补丁的更快方法?
- acumatica - 如何禁用员工考勤卡 (EP406000) 的“更新”按钮
- rest - 将 REST-API 的响应放入变量 Windows 批处理文件中
- r - 如何使用激活的“setspace”和“footmisc”包跳转到脚注?
- java - sharedpreferences 为什么不返回任何值
- azure - 如何为 Azure Function app v2.0 设置无限超时
- c# - 在使用 DateTimeOffset.TryParseExact 时遇到 AM/PM 问题
- c - C程序,从涉及精度小数的用户输入中打印出最大值和最小值
- powerapps - powerapps 添加图片方式 如何添加多个
- visual-studio-2015 - 如何在nmake中转义双引号