【问题标题】:How to find the threadID of a Azure Pull Request?如何找到 Azure 拉取请求的 threadID?
【发布时间】:2019-06-08 13:43:14
【问题描述】:

我正在尝试使用 Powershell 中的 Azure API 对 PR 发表评论。

我找到了这个资源:https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20request%20thread%20comments/create?view=azure-devops-rest-5.0

我已经实现了:

$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 的拉取请求的评论部分的图片:

那么,PR 的thread id 是什么?

【问题讨论】:

    标签: azure azure-devops


    【解决方案1】:

    我通过使用 API 想通了:

    https://dev.azure.com/$organization/$project/_apis/git/repositories/$repositoryId/pullRequests/$pullRequestId/threads?api-version=5.0

    您可以获得该 PR 的线程列表。评论部分的每一行代表一个线程。我认为线程 id 与 PR 相关联(即created by PB 是该 PR 内的线程 id 1),但事实并非如此。每个新线程都会增加线程 ID。因此,如果我在不同的 PR 中添加一个线程,它的线程 ID 可能是 231。如果我在不同的 PR 中添加另一个线程,它将具有 id 232。这很烦人。我不明白为什么 Azure 会以这种方式实现它。

    【讨论】:

    • 显然是因为它们存储在一个单独的表中,并且具有唯一的 ID,每个线程都会递增。
    • 这有多明显?你能提供任何文件吗?
    • 从你描述的实现中可以明显看出
    猜你喜欢
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多