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

B Jayachithra 51 Reputation points
2022-11-23T12:59:43.693+00:00

Hi,

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: com.microsoft.graph.http.GraphServiceException: Error
code: ErrorInvalidIdMalformed
Error message: Id is malformed.

POST https://graph.microsoft.com/v1.0/users/<userid>/messages/<msg id>/microsoft.graph.copy
SdkVersion : graph-java/v5.41.0 "

Can you help how to fix issue?

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Vicky Kumar (Mindtree Consulting PVT LTD) 1,161 Reputation points Microsoft Employee
    2022-11-23T17:24:25.063+00:00

    Try with below API call, please see the doc for more details - https://learn.microsoft.com/en-us/graph/api/message-copy?view=graph-rest-1.0&tabs=http

    POST - https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/messages/{id}/copy

    1 person found this answer helpful.
    0 comments No comments

  2. Shivam Dhiman 6,081 Reputation points
    2022-11-23T21:43:04.737+00:00

    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.
    263604-1.png

    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

    263573-2.png

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

    263644-3.png

    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.

    1 person found this answer helpful.

  3. B Jayachithra 51 Reputation points
    2022-11-28T05:59:38.273+00:00

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


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.