title: User PowerShell to Queue a Build in Azure Devops
body: <p>There are a few related questions in stack I'll drop them below. I'm working with Azure DevOps api 5.1 and attempting to queue a build. </p>
  
  <pre><code>{
      "Definition": {
          "id": "7"
      }
  }
  </code></pre>
  
  <p>This will queue a build with the variables that are already set in the definition. I have attempted to pass in variables in a few different ways both of which wound up not being honored by the API at all.</p>
  
  <pre><code>{
      "Definition": {
          "id": "7",
          "variables": {
              "tag": "@{value=v1.1.0}",
              "system.debug": "@{value=true}"
          }
      }
  }
  </code></pre>
  
  <p>Per some of the related questions I also attempted</p>
  
  <pre><code>{
      "Definition": {
          "id": "7",
          "parameters": {
              "tag": "@{value=v1.1.0}",
              "system.debug": "@{value=true}"
          }
      }
  }
  </code></pre>
  
  <p>After capturing the output from chrome while queuing a build via the UI it appears to expect variables as opposed to parameters, but what i'm seeing when i go back to view the builds is that the variables being passed in are not being honored. Additionally I have taken the definition I wish to run and stashed it into the body.definition above. </p>
  
  <p><a href="https://stackoverflow.com/questions/50838651/vsts-use-api-to-set-build-parameters-at-queue-time">VSTS use API to set build parameters at queue time</a></p>
  
  <p><a href="https://stackoverflow.com/questions/50176797/tfs-2017-api-queuing-a-build-with-variables">TFS 2017 API; Queuing a build with variables</a></p>
  
  <p><a href="https://stackoverflow.com/questions/50483072/how-to-queue-a-new-build-using-vsts-rest-api">How to QUEUE a new build using VSTS REST API</a></p>
  
  <p>Please let me know if I should add more detail I've not put the actual code, but it is pretty straightforward</p>
  
  <pre><code>Invoke-RestMethod -Method post -Uri $uri -Headers $Header -ContentType 'application/json' -Body ($Body |ConvertTo-Json -Compress -Depth 10)
  </code></pre>