0
votes

I am attempting to build key rotation for my service connections. However when following the Rest API Docs I keep getting the following error.

https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/update%20service%20endpoint?view=azure-devops-rest-5.1

$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"": ""[email protected]"",
        ""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

This is the error I receive when making the call.

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

What parameter is null? The documentation does not list anything that mentions endpoint or type name.

1

1 Answers

2
votes

Missed a comma after authorization.

Thanks,