How to Safely Include Slashes in Graph API Requests for Outlook Event IDs

Shiro 0 Reputation points
2025-08-07T03:14:36.99+00:00

When developing an Outlook Office Add-in, event IDs are stored in a database after registration from Outlook. Subsequently, the web application queries the Graph API to retrieve event details using the endpoint me/events/{event-id}.

A problem arises when event IDs contain slashes (/), leading to errors in the API requests. Attempts to encode the slash as %2F have not resolved the issue. A workaround using hyphens (-) allows the request to succeed, but this poses a risk of ID collisions between similar event IDs.

What is the recommended approach for safely including event IDs with slashes in Graph API requests? The use of $filter with id was also tested, but it appears that id is not a supported filter field.

Any insights or recommendations would be greatly appreciated.

Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments
{count} votes

Accepted answer
  1. Flora-T 2,165 Reputation points Microsoft External Staff Moderator
    2025-08-07T08:55:51.81+00:00

    Dear Shiro

    Thanks for raising this important issue on Microsoft Q&A Forum.

    You're absolutely right to be cautious when dealing with event identifiers that contain slashes (/), as they can break API requests if used directly in the URL path. Typically, event IDs generated by Outlook are GUIDs that do not contain slashes. However, if the event is synced from external systems, or is an exception to a recurring event, the ID may include special characters such as slashes (/).

    Even when URL-encoded as %2F, these slashes are still interpreted by the Graph API as path separators. And while replacing slashes with hyphens (-) may work as a workaround, it introduces the risk of ID collisions, especially if your system stores both original and transformed IDs.

    Based on my research, I recommend retrieving the event using $filter with iCalUId instead of querying by id, which is a stable and unique identifier across clients and calendars.

    Example Request:

    GET https://graph.microsoft.com/v1.0/me/events?$filter=iCalUId eq '040000008200E00074C5B7101A82E00800000000C0F5A8D1E2D7D901000000000000000010000000F8E6E6B0A0E14E4A8E6E6A6E6A6E6A6E'
    
    • Headers: Include Authorization: Bearer {access_token} and optionally Prefer: outlook.timezone="UTC" for consistent time handling.

    Response: An array of matching events (expect one).

    Additional Notes:

    • This works in both v1.0 and beta endpoints.

    If you're dealing with recurring events, note that each instance may share the same iCalUId as the series master, but you can combine with other filters like start/dateTime if needed.

    For cross-calendar consistency (e.g., if events move), iCalUId remains stable, unlike id which can change.

    Test in Microsoft Graph Explorer to verify.

    This method eliminates encoding issues and collision risks while providing a reliable way to fetch event details. If your scenario involves events across multiple users or calendars, use /users/{userId}/events instead of /me/events

    If possible, please provide your call ID to test on my environment (via private message).

    Thanks again for bringing this up, many developers may also encounter when working with Microsoft Graph and Outlook event IDs.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".User's imageNote: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

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.