I am using PowerShell to remove a user from a Team in a project .Below is the code.
$AzureDevOpsPAT = "XXXXXXXXXXXXXXXXX"
$groupid = "vssgp.UyXXXXXXXXXXXXXXUxMjkzxx"
$memberid = "tester.deer@dmain.com"
$AzureDevOpsAuthenicationHeader = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)"))
$saasheaders = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$saasheaders.Add("Authorization", "Basic $AzureDevOpsAuthenicationHeader")
$saasheaders.Add("Accept", "*/*")
$saasheaders.Add("Cache-Control", "no-cache")
$saasheaders.Add("Accept-Encoding", "gzip, deflate")
$saasheaders.Add("Content-Type", "application/json")
$result = Invoke-RestMethod "https://vsaex.dev.azure.com/mycollectionname/_apis/GroupEntitlements/$groupid/members/$memberid`?api-version=5.1-preview.1" -Method 'DELETE' -Headers $saasheaders
Write-Host "value is $result"
Below is the error I get
Invoke-RestMethod : {"count":1,"value":{"Message":"The request is invalid."}}
+ ... result = Invoke-RestMethod "https://vsaex.dev.azure.com/myorganization/_apis ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
I am following the documentation from this link
Any suggestions what am I doing wrong ?