Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use "Pull Request Query"?

I want to return a pull request based on a commit. I found this > https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull%20request%20query/get?view=azure-devops-rest-5.1

This API is used to find what pull requests are related to a given commit.

I'm using the following code:

$body = @"
{
    "items": [
        {
            "59c1c31397b266116ff6d735e5638ef5d1b598a0"
        }
    ]
}
"@ 

$someLink = "https://dev.something.com/embrace/somethingSomething/_apis/git/repositories/****-bf64-47d9-8b10-53f21220d54d/pullrequestquery?api-version=5.1"
Invoke-RestMethod -Uri $someLink -Headers @{Authorization = $pat } -Body $body -Method Post -ContentType 'application/json'

When I run the release I get a:

The remote server returned an error: (400) Bad Request.

like image 340
Peter Boomsma Avatar asked May 01 '26 18:05

Peter Boomsma


1 Answers

Try using the following body:

$body = @"
{
    "queries": [{
        "items": [
            "59c1c31397b266116ff6d735e5638ef5d1b598a0"
        ],
        "type": "commit"
    }]
}
"@ 
like image 176
Thiago Custodio Avatar answered May 04 '26 09:05

Thiago Custodio