title: Azure DevOps Server Invoke-RestMethod Error: No API version provided for the "PUT" request
body: <p>Based on this <a href="https://gist.github.com/tegaaa/e14820ccf7ea99ba2ef9d0c3cc180df4" rel="nofollow noreferrer">PowerShell example</a> from Etienne Tremblay I try to pass data to the Azure DevOps Server (2019.0.1) REST API.</p>
  
  <p>In this example I would like to modify the description text of a project (just for test reasons):</p>
  
  <pre><code># DEMO 5 Update an environement build variable
  Write-Host "Demo 5"
  $projects.value | ForEach-Object {
      $project = $_.name
      $buildManagementAreaId = "efc2f575-36ef-48e9-b672-0c6fb4a48ac5"
      $tfsBaseUrl = GetUrl -orgUrl $orgUrl -header $header -AreaId $buildManagementAreaId
  
      # https://docs.microsoft.com/en-us/rest/api/azure/devops/build/definitions/list?view=azure-devops-rest-5.0
      $relDefUrl = "$tfsBaseUrl$project/_apis/build/definitions?api-version=5.0"
      Write-Host "Requesting URL: $relDefUrl" -ForegroundColor Yellow
      $result = Invoke-RestMethod $relDefUrl -Method Get -ContentType "application/json" -Headers $header
      $relDefs = $result.value
  
      if($relDefs.count -gt 0){
          Write-Host "$project $($relDefs.count) build def founds" -ForegroundColor Blue
          $relDefs | ForEach-Object {
  
              $relDef = $_
              $relDefExpanded = Invoke-RestMethod "$($relDef.url)?`$Expand=Environments&amp;api-version=5.0" -Method Get -ContentType "application/json" -Headers $header
              $relDefExpanded.project.description = "Hallo!!!"
  
              $body = $relDefExpanded | ConvertTo-Json -Depth 100 -Compress
              $body = [System.Text.Encoding]::UTF8.GetBytes($body)
  
              #ERROR OCCURS HERE
              $updateResult = Invoke-RestMethod "$($relDef.url)?api-version=5.0" -Method Put -ContentType "application/json" -body $body -Headers $header 
              Write-host "Variable value after: $($updateResult.project.description)" -ForegroundColor Green
          }
      }
  }
  </code></pre>
  
  <p>Hints:</p>
  
  <ul>
  <li><code>$projects</code> get defined before in the script (demo1) </li>
  <li>the original script change a variable not a description (both versions don't work)</li>
  </ul>
  
  <p><strong>The Error occurs on:</strong></p>
  
  <pre><code>$updateResult = Invoke-RestMethod "$($relDef.url)?api-version=5.0" -Method Put -ContentType "application/json" -body $body -Headers $header 
  </code></pre>
  
  <p><strong>with the message:</strong></p>
  
  <pre><code>Invoke-RestMethod: {"$ id": "1", "innerException": null, "message": "No API version provided for the" PUT "request The version must either be part of the" Accept "header (eg
  \ "application / json; api-version = 1.0 \") or as a query parameter (for example, "? api-version = 1.0")
  . Will "," type name ":" Microsoft.VisualStudio.Services.WebApi.VssVersionNotSpecifiedException,
  Microsoft.VisualStudio.Services.WebApi","typeKey":"VssVersionNotSpecifiedException","errorCode":0,"eventId":3000}
  In C:\Users\mkober\Desktop\Azure DevOps Console\WriteAPI.ps1:75 Zeichen:29
  + ... ateResult = Invoke-RestMethod "$($relDef.url)?api-version=5.0" -Metho ...
  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
  </code></pre>
  
  <p><strong>Final URL:</strong></p>
  
  <pre><code>http://138.202.18.216:8070/Samples/19e02b27-74ab-40dd-a519-ece38fafa870/_apis/build/Definitions/11?revision=5?api-version=5.0
  </code></pre>