In continuation of my older post where we discussed how to associate/assign role with a user or a team https://vishalgrade.com/2020/09/10/assign-security-role-to-team-and-user-through-rest-api-in-ms-crm/
Let’s see how we can remove N to N (Many to Many) tables association using rest api:
For example, let’s say i want to remove a role from a user which is N to N association, we would make below request with delete method:
Method: Delete Url: https://[Your instance url]/api/data/v9.1/[primaryntitysetname]([PrimaryEntityId])/[RelationShipName]/$ref?$id=[Your instance url]/api/data/v9.1/[secondaryentitySetName]([SecondaryentityId])
Which will effectively be something like this:
Method: Delete Url: https://[yourinstance].api.crm9.dynamics.com/api/data/v9.1/systemusers(2a24eebd-b6d7-ea11-a813-001dd8018976)/systemuserroles_association/$ref?$id=https://[yourinstance].api.crm9.dynamics.com/api/data/v9.1/roles(B1AA26D1-72EA-E911-A989-001DD8009F4B)
Just replace [yourinstance] with your instance name and change guids and try it out.
Hope it would be helpful.
Leave a Reply