Graph API Remove Member is deleting User instead of removing User from Group

Mohana Arunachalam Srinivasan 96 Reputation points
2021-11-30T15:26:26.283+00:00

Hi,

I'm trying to use the Graph API to create/update/delete groups and also add/remove members to groups and I was facing permission issues to remove a user from a group.
I'm using this (https://learn.microsoft.com/en-us/graph/api/group-delete-members?view=graph-rest-1.0&tabs=http) on my sandbox AAD and I tried adding different permissions from least to most privileged, but nothing worked.
So I decided to use my global admin user to test the same call, and the user was completed deleted instead of being removed from the group. I was able to restore the user from "Deleted users" and then repeat the tests again.
I've shared the verbose output from my most recent call.

INFO: Request URL: 'https://graph.microsoft.com/v1.0/groups/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/members/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/'
INFO: Request method: 'DELETE'
INFO: Request headers:
INFO: 'User-Agent': 'python/3.10.0 (Linux-5.14.18-300.fc35.x86_64-x86_64-with-glibc2.34) AZURECLI/2.30.0 (PIP)'
INFO: 'Accept-Encoding': 'gzip, deflate'
INFO: 'Accept': '/'
INFO: 'Connection': 'keep-alive'
INFO: 'Content-Type': 'application/json'
INFO: 'x-ms-client-request-id': '510024b8-49c5-4864-9a79-cb519494b7df'
INFO: 'CommandName': 'rest'
INFO: 'ParameterSetName': '--method --url --headers --body --verbose'
INFO: 'Authorization': 'Bearer xxxxxxxxxxxxx...'
INFO: 'Content-Length': '102'
INFO: Request body:
INFO: {"@odata.id":"https://graph.microsoft.com/v1.0/directoryObjects/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}
INFO: Response status: 204
INFO: Response headers:
INFO: 'Date': 'Tue, 30 Nov 2021 15:06:03 GMT'
INFO: 'Content-Length': '0'
INFO: 'Cache-Control': 'no-cache'
INFO: 'Strict-Transport-Security': 'max-age=31536000'
INFO: 'request-id': '9758aaf9-bbf5-4056-aa79-aaf4ef9549e3'
INFO: 'client-request-id': '9758aaf9-bbf5-4056-aa79-aaf4ef9549e3'
INFO: 'x-ms-ags-diagnostic': '{"ServerInfo":{"DataCenter":"West Europe","Slice":"E","Ring":"5","ScaleUnit":"001","RoleInstance":"AM4PEPF00012FF6"}}'
INFO: 'x-ms-resource-unit': '1'
INFO: Response content:
INFO:
INFO: Command ran in 0.532 seconds (init: 0.099, invoke: 0.432)

Let me know if you need more details or if I'm doing something wrong.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,715 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,664 questions
{count} votes

Accepted answer
  1. Mohana Arunachalam Srinivasan 96 Reputation points
    2021-11-30T17:16:03.397+00:00

    Welp. My own comment hinted at the problem.
    The $ref was being looked up by shell during execution as an environment variable and was being replaced with blank effectively removing the $ref at the end.

    Enclosing the url in single quotes fixed my problem.


0 additional answers

Sort by: Most helpful