0
votes

I can't figure out how to compose the request body described in this article.

https://docs.microsoft.com/en-us/rest/api/vsts/git/pull%20request%20query/get?view=vsts-rest-4.1#gitpullrequestqueryinput

I keep getting this error, regardless of if I have queries in my payload or not:

Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Invalid argument value.\r\nParameter name: queries","typeName":"Microsoft.TeamFoundation.SourceControl.WebServer.InvalidArgumentValueException, Microsoft.TeamFoundation.SourceControl.WebServer","typeKey":"InvalidArgumentValueException","errorCode":0,"eventId":0}

I was attempting something like this:

$body= @{
    queries=@(
        @{
            items=@(0,1,2)
            type="commit"
        }
    )
    results=@()
} | ConvertTo-Json
1
Invoke-RestMethod Takes an object as input, not a json String. It does the conversion on its own.Clijsters
It seems to work fine, example: $body= @{ item= "test" } | convertto-json $url = "https://reqres.in/api/users" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $resp = Invoke-RestMethod -Method Post -Uri $url -Body $body -UseBasicParsing $respJustin Holbrook

1 Answers

0
votes

I had the json format right, but not adding -depth on the end was my failure.

$body = @{
  queries=@(
    @{
        items = @("xxxx")
        type = "commit"
    }
  )
  results=@()
} | ConvertTo-Json -Depth 5