title: How to find the threadID of a Azure Pull Request?
body: <p>I'm trying to post a comment on a PR using the Azure API in Powershell. </p>
  
  <p>I've found this resource: <a href="https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20request%20thread%20comments/create?view=azure-devops-rest-5.0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20request%20thread%20comments/create?view=azure-devops-rest-5.0</a></p>
  
  <p>And I've implemented it:</p>
  
  <pre><code>$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
  </code></pre>
  
  <p>When I run this with <code>$threadId = 1</code> I get:</p>
  
  <blockquote>
    <p>Invoke-RestMethod : {"$id":"1","innerException":null,"message":"The requested>  pull request comment thread '1' cannot be found.</p>
  </blockquote>
  
  <p>When I run it with <code>$threadId = 0</code> I get:</p>
  
  <blockquote>
    <p>Invoke-RestMethod : {"$id":"1","innerException":null,"message":"The value 0 is outside of the allowed range</p>
  </blockquote>
  
  <p>This is a image of the comment section of the pull request with id 1:</p>
  
  <p><a href="https://i.stack.imgur.com/0N0nb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0N0nb.png" alt="enter image description here"></a></p>
  
  <p>So what is the <code>thread id</code> of a PR?</p>