Making the message ID immutable using Prefer: IdType="ImmutableId"

Praveen Santhosh 0 Reputation points
2024-03-05T13:34:30.0766667+00:00

Hi,

I'm working with Mail endpoints in the Graph API to send and move messages from one folder to another within the same mailbox.

I have a requirement to make the message ID to be the same even after moving the message to another folder. I tried using the Immutable ID header but, the message ID is changing.

Any guidance will be helpful.

Thanks in advance.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,913 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
4,958 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 38,196 Reputation points
    2024-03-06T03:23:19.2066667+00:00

    Hi @Praveen Santhosh

    This header needs to be included in every API request to ensure the ID remains immutable. If the message ID is still changing after including this header, it could be due to not including it in all the requests or a potential issue with the implementation.

    Here's a general approach to ensure the message ID remains the same:

    1. Include the Prefer: IdType="ImmutableId" header in the initial API request when creating or getting the message.
    2. Use the same header when sending the message.
    3. Again, include the header when moving the message to another folder.

    This header only applies to the request it is included with, so it's crucial to include it in every request related to the message you want to keep the ID immutable for.

    Hope this helps.

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