Issue with move folder API in Microsoft Graph when Email ID contains "/"

Waqar Ahmed 0 Reputation points
2024-05-09T04:23:23.2433333+00:00

When attempting to move a folder using the following endpoint:

Endpoint: https://graph.microsoft.com/v1.0/me/messages/{EmailId}/move

I'm encountering an error when the EmailId parameter contains a "/" symbol. Despite trying to encode the Email ID, the API continues to return an error.

It's important to note that the API works as expected when the Email ID does not contain a "/" symbol.

I have already attempted to encode the Email ID using URL encoding, but the issue persists. Additionally, escaping the "/" character did not resolve the problem.

The API should be able to move the folder regardless of whether the Email ID contains a "/" symbol.

Following is the code (it is working fine if emailId didn't has "/")

using (var httpClient = new HttpClient())
{
    string encodedEmailId = HttpUtility.UrlEncode(emailId);

    var request = new HttpRequestMessage(HttpMethod.Post, $"https://graph.microsoft.com/v1.0/me/messages/{encodedEmailId}/move");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
    request.Content = new StringContent($"{{\"DestinationId\": \"{folderId}\"}}", Encoding.UTF8, "application/json");

    var response = await httpClient.SendAsync(request);

    string errorMessage = await response.Content.ReadAsStringAsync();
}

Following is the error

{"error":{"code":"RequestBroker--ParseUri","message":"Resource not found for the segment 'vUqoAAAIBDAAAANbsh1sqmahFnro5xH'."}}`

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,779 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,356 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 37,626 Reputation points
    2024-05-09T10:01:30.9033333+00:00

    Hi @Waqar Ahmed

    This seems to be an issue with the MS Graph server, it cannot correctly parse the special character "/", and mistakenly treats it as a path separator.

    I suggest you report this issue to Microsoft Graph or open a support ticket for it.

    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.