An API that connects multiple Microsoft services, enabling data access and automation across platforms
The ErrorInvalidIdMalformed response indicates that the {id} segment in the URL is not in the format Microsoft Graph expects for a message ID.
Key points from the context:
- To get the MIME content of a message, the supported pattern is:
or for the signed-in user:GET /users/{id}/messages/{id}/$value
TheGET https://graph.microsoft.com/v1.0/me/messages/{message-id}/$value{message-id}here must be the Graph message ID returned by Microsoft Graph (for example from a priorGET /messagesorPOST /messages), not the EWSItemIdor another legacy identifier. - When migrating from EWS to Graph, using the old EWS
ItemIddirectly as the{id}path parameter will causeErrorInvalidIdMalformed, because Graph cannot parse that ID as a valid Graph message ID. - The context also notes that the MIME content is returned when
$valueis appended and the response starts with theMIME-Versionheader, confirming that the call pattern itself is correct once a valid Graph message ID is used.
Given this, the issue is most likely:
- The
itemIdbeing URL-encoded and used in the path is not a Graph message ID. - URL-encoding alone (for example via
URLEncoder.encode(itemId, StandardCharsets.UTF_8)) does not convert an EWS ID into a Graph ID; it only makes it safe for use in a URL.
To resolve:
- Ensure that the
{id}in/users/{user}/messages/{id}/$valueis the actualidproperty returned by Microsoft Graph for that message. - If only an EWS
ItemIdis available, first locate the corresponding message in Graph (for example by querying on other properties such as subject, sent/received time, or internet message ID) and then use the Graphidfrom that result in the$valuecall. - Keep URL encoding limited to making the Graph
idpath-safe; do not attempt to reuse or transform EWS IDs as Graph IDs.
References: