GRAPH - Add/remove user to distribution list

New Contributor

Good evening, for about a week, through a small program that uses graph api, the addition / removal of users from distribution lists no longer works; do you have any idea why? I have many processes that use graph api and they never gave me problems; we thought it was a temporary problem, but after a week it still doesn't work (attached the error)

2 Replies

Hi @micheleariis

 

It is not possible to add user via the Graph API to a distribution list. 

Add members - Microsoft Graph v1.0 | Microsoft Docs

 

Mr_Helaas_0-1638724161658.png

 

 

Removing people is however possible

Remove member - Microsoft Graph v1.0 | Microsoft Docs

 

Delete https://graph.microsoft.com/beta/groups/{group id}/members/{user id}

 

One of the option you could consider is to use the Exchange online PowerShell command.

 

Install-module ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement

Connect-ExchangeOnline
Get-DistributionGroup

#Copy name of distribution list

 Get-DistributionGroupMember -Identity "<DL name>"

  Add-DistributionGroupMember -Identity "<DL name>" -Member "<email user>"

 

Kind regards,

 

Rene

 

Through powershell there is no problem, I would like to be able to do it directly from graph (Microsoft must have disabled it, up to 1 month ago it worked without problems). We used a mixed graph / c # code, at most I could do it directly from c # but I don't know how to do it.