Forum Discussion
Frank_Cheung_Quilter
Mar 01, 2024Copper Contributor
able to save security group multiple times with same mailNickName
hi, i ran this code 3 times and it created a new security group every time (returning different group ids).
i thought mailNickname was enforced to be unique? please advise.
- You can do a check via the $search query operator: https://learn.microsoft.com/en-us/graph/search-query-parameter?tabs=http#using-search-on-directory-object-collections
https://graph.microsoft.com/beta/groups?$search="mailNickname:blabla"
- It is, but only for Exchange recipients. Which a non mail-enabled security group is not 🙂
- Frank_Cheung_QuilterCopper Contributor
thanks, how can i enforce uniqueness in my code?
i am trying to automate the creation of security groups and it won't be nice if people can create duplicates.
- You can do a check via the $search query operator: https://learn.microsoft.com/en-us/graph/search-query-parameter?tabs=http#using-search-on-directory-object-collections
https://graph.microsoft.com/beta/groups?$search="mailNickname:blabla"