How to QUEUE a new build using VSTS REST API : <p>I have the following script</p>

<pre><code>Param(
   [string]$vstsAccount = "abc,
   [string]$projectName = "abc",
   [string]$user = "",
   [string]$token = "xyz"
)

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$verb = "POST"


$body = @"
{

    "definition": {
         "id": 20
    }
}
"@


$uri = "https://$($vstsAccount).visualstudio.com/DefaultCollection/$($projectName)/_apis/build/builds?api-version=4.1"
$result = Invoke-RestMethod -Uri $uri -Method $verb -ContentType "application/json" -Body (ConvertTo-Json $body)  -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
</code></pre>

<p>However I get this error</p>

<pre><code>Invoke-RestMethod : {"$id":"1","innerException":null,"message":"This request expects an object in the request body, but the supplied data could not be 
deserialized.","typeName":"Microsoft.TeamFoundation.Build.WebApi.RequestContentException,
</code></pre>

<p>So I tried to queue a build from the browser and see the payload using developer tools:</p>

<pre><code>{"queue":{"id":70},"definition":{"id":20},"project":{"id":"b0e8476e-660a-4254-a100-92ef0ec255e5"},"sourceBranch":"refs/heads/master","sourceVersion":"","reason":1,"demands":[],"parameters":"{\"system.debug\":\"false\"}"}
</code></pre>

<p>So, I replaced that into my script:</p>

<pre><code>$body = @"
{"queue":{"id":70},"definition":{"id":20},"project":{"id":"b0e8476e-660a-4254-a100-92ef0ec255e5"},"sourceBranch":"refs/heads/master","sourceVersion":"","reason":1,"demands":[],"parameters":"{\"system.debug\":\"false\"}"}
"@
</code></pre>

<p>However I keep getting the same error.</p>

<p>The official documentation for this endpoint is here, but its not clear 
<a href="https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/queue?view=vsts-rest-4.1#request-body" rel="noreferrer">https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/queue?view=vsts-rest-4.1#request-body</a></p>
