How to fix "Error code: ErrorInvalidIdMalformed Error message: Id is malformed" when trying to copy message which was sent in previous step?

B Jayachithra 1 Reputation point


I am trying to perform below steps using MS Graph API

  1. Send mail to mailbox
  2. Copy same message that was sent in step1 to folder based on some condition

While trying to copy,it fails with below message
"SEVERE: Throwable detail: Error
code: ErrorInvalidIdMalformed
Error message: Id is malformed.

POST<userid>/messages/<msg id>/microsoft.graph.copy
SdkVersion : graph-java/v5.41.0 "

Can you help how to fix issue?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,437 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Vicky Kumar (Mindtree Consulting PVT LTD) 1,166 Reputation points Microsoft Employee

    Try with below API call, please see the doc for more details -

    POST -{id | userPrincipalName}/messages/{id}/copy

    0 comments No comments

  2. Shivam Dhiman 5,951 Reputation points

    Hi @B Jayachithra

    I have tried to replicate your scenario and I am facing the same error when the destinationId or message id is wrong. Please refer to the below sample screenshot.

    1. Please make sure you are using the correct message id. To verify you can use this GET /users/{id | userPrincipalName}/messages/{id} Graph API endpoint
    2. Also please make sure you are using the correct destinationId. To get the destination folder ID use this GET /users/{id | userPrincipalName}/mailFolders Graph API


    After passing the right id I was able to get desired result.


    For more details, please refer to this documentation.

    Hope this helps.

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

  3. B Jayachithra 1 Reputation point

    Hi ShivamDhiman-1582,
    Any update on handling this scenario in batch?