title: Updating a service connection via the rest api
body: <p>I am attempting to build key rotation for my service connections. However when following the Rest API Docs I keep getting the following error. </p>
  
  <p><a href="https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/update%20service%20endpoint?view=azure-devops-rest-5.1" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/update%20service%20endpoint?view=azure-devops-rest-5.1</a></p>
  
  <pre><code>$projectApi = "https://dev.azure.com/collection/teamproject/_apis/serviceendpoint/endpoints/ffffffff-ffff-ffff-ffff-ffffffffffff?api-version=5.0-preview.2"
  $json = "{
      ""data"": {
          ""subscriptionId"": ""ffffffff-ffff-ffff-ffff-ffffffffffff"",
          ""subscriptionName"": ""subscriptionName"",
          ""environment"": ""AzureCloud"",
          ""scopeLevel"": ""Subscription"",
          ""creationMode"": ""Manual""
      },  
      ""id"": ""ffffffff-ffff-ffff-ffff-ffffffffffff"",
      ""name"": ""Azure Service Connection"",
      ""type"": ""azurerm"",
      ""url"": ""https://management.azure.com/"",
          ""createdBy"": {
          ""id"": ""ffffffff-ffff-ffff-ffff-ffffffffffff"",
          ""displayName"": ""me"",
          ""uniqueName"": ""me@domain.onmicrosoft.com"",
          ""url"": ""https://spsprodcus3.vssps.visualstudio.com/ffffffff-ffff-ffff-ffff-ffffffffffffe/_apis/Identities/ffffffff-ffff-ffff-ffff-ffffffffffff"",
          ""imageUrl"": ""https://dev.azure.com/teamproject/_apis/GraphProfile/MemberAvatars/aad.ffffffffffffffffffffffffffffffffffffffffffffffff""
      },
      ""authorization"": {
          ""parameters"": {
              ""tenantid"": ""ffffffff-ffff-ffff-ffff-ffffffffffff"",
              ""serviceprincipalid"": ""test"",
              ""authenticationType"": ""spnKey"",
              ""serviceprincipalkey"": ""test""
          },
          ""scheme"": ""ServicePrincipal""
      }
      ""isReady"": true
  }
  "
  $result = Invoke-RestMethod -Uri $projectApi -Method Put -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $DevOpsAuthentication)} -Body $json
  
  </code></pre>
  
  <p>This is the error I receive when making the call.</p>
  
  <blockquote>
    <p>Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Value
    cannot be null.\r\nParameter name: 
    endpoint","typeName":"System.ArgumentNullException,
    mscorlib","typeKey":"ArgumentNullException","errorCode":0,"eventId":0}
    At C:\temp\Scripts\ServiceConnectionsTemp.ps1:49 char:11
    + $result = Invoke-RestMethod -Uri $projectApi -Method Put -ContentType ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  + CategoryInfo : InvalidOperation:
    (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod],
    WebException  + FullyQualifiedErrorId :
    WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand</p>
  </blockquote>
  
  <p>What parameter is null? The documentation does not list anything that mentions endpoint or type name.</p>