Azure-Devops remove user from projectContributor via Rest API RRS feed

  • Question

  • Azure-Devops, Using PowerShell I am attempting to remove a user from groupType projectContributor so I can move him to the Project Team. I can accomplish the add to the Project Team however I have tried everything I can to remove this users entitlement using a PATCH without success. FYI to avoid comments, OrgUrl, projectId and userId are being passed.

    $b= @"
            "op": "remove",
            "path": "/projectEntitlements",
            "value": {
                "projectRef": {
                    "id": "$projectID"
                "group": {
                    "groupType": "projectContributor"
    $uri = "$orgURL/_apis/userentitlements/$userId`?api-version=5.1-preview.2"
    Invoke-RestMethod -Uri $uri -ContentType "application/json-patch+json" -Body $b -Method PATCH -Headers @{ Authorization = ("Basic {0}" -f $base64AuthInfo)}

    The error I am getting is this:

    projectId","typeName":"System.ArgumentException, mscorlib","typeKey":"ArgumentException","errorCode":0,"eventId":0}
    At line:20 char:1
    + Invoke-RestMethod -Uri $uri -ContentType "application/json-patch+json ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

    Tuesday, May 5, 2020 9:46 PM