I am using Graph API for outlook contact, Delete contact for other user contact is not working

2024-10-16T12:54:11.57+00:00

I have permission to use Outlook contacts in the Azure app (readWrite) application and delegate both.
I can Get, Create, and Edit other user contacts but I am not able to delete other user's contacts but I can delete my contacts.
Working for my contact: DELETE /me/contacts/{id}
While testing with Graph Explorer I am getting the below error:
DELETE /users/{id | userPrincipalName}/contactFolders/{id}/contacts/{id} - it is not deleted and gives error - {"error":{"code":"ErrorCannotDeleteObject","message":"Object cannot be deleted."}}

Please let me know the solution to achieve this

Outlook Windows Classic Outlook for Windows For business
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Hitesh Pachipulusu - MSFT 3,620 Reputation points Microsoft External Staff
    2024-10-16T14:33:00.46+00:00

    Hello Arpan Parekh | Redian Software India,

    Thank you for reaching out to Microsoft Support!

    It sounds like you're encountering a permissions issue when trying to delete other users' contacts. Here are a few things you can check and try:

    1. Permissions: Ensure that your app has the necessary permissions. While you mentioned having readWrite permissions, double-check that these permissions are correctly configured for deleting contacts.
    2. Ownership: Verify if the contacts you are trying to delete are owned by the user or if they are part of a shared or global address list. Contacts in a global address list or shared contacts might have restrictions.
    3. API Endpoint: Make sure you are using the correct API endpoint. For deleting a contact, the endpoint should be:
         DELETE /users/{user-id}/contactFolders/{contactfolder-id}/contacts/{contact-id}
      
      Ensure that the user-id , contactfolder-id and contact-id are correctly specified. Also check whether the contactfolder is existing or not.
    4. Error Details: The error message ErrorCannotDeleteObject suggests that the object might be protected or linked to another object that prevents deletion. Check if there are any dependencies or links that need to be resolved before deletion.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.