How to restore a Deleted Calendar Event Using Graph API
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the Graph SDK Java deletion calls and the mailFolders/messages recovery query shown in the issue. Determine whether permanentDelete() and delete() place calendar events in different locations, identify the correct Recoverable Items endpoint or folder ID, and verify that the event can be found for restoration.
Written by the indexing model from the issue text.
Description
Context
We are currently migrating functionality from EWS to Microsoft Graph API (Java). We have a requirement to delete and then programmatically restore calendar events. While our EWS implementation works perfectly, we are struggling to locate the deleted events using the Graph API.
Current EWS Implementation (Working)
In EWS, we use DeleteMode.HardDelete and then search the RecoverableItemsPurges folder to move the item back to the Calendar.
// How we delete meeting from calendar
if (msg instanceof MeetingMessage) {
MeetingMessage meetingMessage = MeetingMessage.bind(service, msg.getId());
ItemId masterId = meetingMessage.getAssociatedAppointmentId();
if (masterId != null) {
Appointment appointment = Appointment.bind(service, masterId);
appointment.delete(DeleteMode.HardDelete);
}
}
// How we restore the message
ItemView itemView = new ItemView(EwsServer.FOLDER_VIEW_PAGE_SIZE);
itemView.setTraversal(ItemTraversal.Shallow);
SearchFilter filterColl = new SearchFilter.SearchFilterCollection(
LogicalOperator.And,
new SearchFilter.IsEqualTo(ItemSchema.Subject, message.getSubject()),
new SearchFilter.IsEqualTo(EmailMessageSchema.Sender, message.getSender().getAddress())
);
FindItemsResults<Item> deletedItems = server.getExchangeService()
.findItems(WellKnownFolderName.RecoverableItemsPurges, filterColl, itemView);
if (deletedItems.getItems().size() > 0) {
for (Item item : deletedItems.getItems()) {
item.move(WellKnownFolderName.Calendar);
break;
}
}
Problem: Graph API Implementation (Not Working)
When using the Graph SDK, we cannot find the event in the recoverable items folders after a deletion.
Deletion code:
graphClient.users().byUserId(mailboxBeingScanned)
.calendar().events().byEventId(eventId)
.permanentDelete().post();
//we have tried delete method as this as well
graphClient.users().byUserId(mailboxBeingScanned)
.calendar().events().byEventId(eventId)
.delete();
Attempted recovery code:
We have tried searching recoverableitemspurges, deleteditems, and recoverableitemsdeletions using the internetMessageId, but the collection always returns empty.
MessageCollectionResponse eventMessage = graphClient.users().byUserId(mailboxBeingScanned)
.mailFolders().byMailFolderId("recoverableitemspurges")
.messages()
.get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "internetMessageId eq '<MN2PR13...prod.outlook.com>'";
});
Questions
-
When using permanentDelete() on a Calendar Event in Graph, does it land in a different folder than it would via EWS?
-
What is the correct mailFolderId or endpoint to query for items in the "Recoverable Items" partition specifically for Calendar events?
- Dominant language
- Java
- Stars
- 444
- Forks
- 154
- Avg merge
- 18h 28m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoftgraph/msgraph-sdk-java
-
status:waiting-for-triage type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoftgraph/msgraph-sdk-java#2610 ·
-
status:waiting-for-triage type:bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
microsoftgraph/msgraph-sdk-java#2656 ·
-
status:waiting-for-triage type:bug
Difficulty 4/5 3-5 days Newbie friendliness 38/100
microsoftgraph/msgraph-sdk-java#2654 ·
-
status:waiting-for-triage
Difficulty 4/5 3-5 days Newbie friendliness 35/100
microsoftgraph/msgraph-sdk-java#2639 ·
-
status:waiting-for-triage type:bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
microsoftgraph/msgraph-sdk-java#2589 · 1 comment ·
All issues in microsoftgraph/msgraph-sdk-java
Similar issues
-
certification
Difficulty 1/5 Under an hour Newbie friendliness 80/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's Openbug ecr
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Needs: Triage Type: Feature request
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
github/copilot-sdk#2760 ·