I'm trying to queue a build using the REST API with on-premises TFS 2015.2 using PowerShell.
$body @{ id = 1 }
Invoke-RestMethod -Method Post -Credential "myusername" -ContentType application/json -Uri "https://{tfsurl}/DefaultCollection/Fabrikam-Fiber-Git/_apis/build/builds?api-version=2.0" -Body (ConvertTo-Json $body)
It throws an error that it needs the definition which needs to be in the JSON. PowerShell doesn't like this, so am I missing a simple syntax error?
$body = @{
"definition": {
"id":1
}
}
I saw this post: How to trigger a build in TFS 2015 using REST API but I don't think it helps much with the PowerShell side of it.