Unable to delete contactFolder (getting ErrorCannotDeleteObject)

Baptiste Martinet 35 Reputation points
2024-05-10T14:46:15.5966667+00:00

Hello,

I'm trying to do a simple delete operation on the user contact folders.

It was working fine until last sunday (05/05/2024).

Since then, I keep getting the following error:

{
	...
	statusCode: 403,
	body: '{"code":"ErrorCannotDeleteObject","message":"Object cannot be deleted."}',
	...
}

I'm almost certain I have all the correct Read/Write permissions and that the ids I'm passing are valid.

Here is the method I use to delete the folder:

  public async deleteUserContactFolder(userId: UserIdentifier, contactFolderId: string)
  {
    return this._client.api(`/users/${userId}/contactFolders/${contactFolderId}`).delete();
  }

Thanks for your help

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,447 questions
{count} vote

Accepted answer
  1. Saranya Madhu-MSFT 455 Reputation points Microsoft Vendor
    2024-05-14T13:38:52.5433333+00:00

    Hello Baptiste Martinet,

    Thanks for reaching Microsoft!

    I am able to replicate your issue.

    I would recommend you raise a support case with Microsoft Graph, a Support Engineer will be able to look into this issue and assist you better. You can raise support ticket from New support request - Microsoft Entra admin center or https://admin.microsoft.com/#/support/requests.

    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Baptiste Martinet 35 Reputation points
    2024-07-17T06:55:35.9166667+00:00

    Hey Martin,

    Not really.

    I guess Microsoft simply does not like when we delete entire contact folders over and over in order to sync our users address books.

    The cleanest solution is to delete contacts within the folder in batches.

    You can delete up to 20 contacts in a single batch.

    What I would suggest is either doing in two times:

    • Get the list of contacts in the folder
    • Delete all of them one by one in batches

    or having a way to remember every contact you've synced and delete/update them in a smarter way.

    Hope it helps,

    Baptiste

    1 person found this answer helpful.
    0 comments No comments