Share via

/mailFolders/{folderId}/messages/delta returns ErrorInvalidIdMalformed in Microsoft Graph API (China - 21Vianet) while the same folderId works fine with /messages

燕芝1 蔡 0 Reputation points
2026-03-03T13:13:31.7233333+00:00

Problem Description

When using the Microsoft Graph API on the China (21Vianet) endpoint, calling /mailFolders/{folderId}/messages/delta returns an ErrorInvalidIdMalformed error, even though the exact same folderId works perfectly fine when calling /mailFolders/{folderId}/messages (non-delta).

The same delta API call works correctly on the Microsoft Graph international endpoint (graph.microsoft.com) without any issues.


Environment

ItemValueEndpoint (China)https://microsoftgraph.chinacloudapi.cn/v1.0Endpoint (International)https://graph.microsoft.com/v1.0SDK@microsoft/microsoft-graph-client v3.xAuth Library@azure/identityAuth FlowClient Credentials (Application Permission)Permission Scopehttps://microsoftgraph.chinacloudapi.cn/.default---

Steps to Reproduce

Step 1: Authenticate against the China endpoint

Authority Host : https://login.chinacloudapi.cn
Scope         : https://microsoftgraph.chinacloudapi.cn/.default

Step 2: Fetch a real folderId via the mailFolders API (no well-known alias used)

GET https://microsoftgraph.chinacloudapi.cn/v1.0/me/mailFolders/inbox

Response:
{
  "id": "AQMkADAwATM0MDAAMS1...",   ← real folderId, not a well-known alias
  "displayName": "Inbox",
  ...
}

Step 3 ✅ Works fine — Call /messages with the real folderId

GET https://microsoftgraph.chinacloudapi.cn/v1.0/me/mailFolders/AQMkADAwATM0MDAAMS1.../messages
     ?$select=id,subject,from,receivedDateTime,isRead,hasAttachments,bodyPreview
     &$top=20
// ✅ Returns 200 OK with message list
{
  "value": [ ... ]
}

Step 4 ❌ Fails — Call /messages/delta with the exact same folderId

GET https://microsoftgraph.chinacloudapi.cn/v1.0/me/mailFolders/AQMkADAwATM0MDAAMS1.../messages/delta
     ?$select=id,subject,from,receivedDateTime,isRead,hasAttachments,bodyPreview
     &$top=20
// ❌ Returns 400 Bad Request
{
  "error": {
    "code": "ErrorInvalidIdMalformed",
    "message": "Id is malformed."
  }
}

Code to Reproduce

import { Client } from "@microsoft/microsoft-graph-client";
import { TokenCredentialAuthenticationProvider } from "@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials";
import { ClientSecretCredential } from "@azure/identity";

const credential = new ClientSecretCredential(tenantId, clientId, clientSecret, {
  authorityHost: "https://login.chinacloudapi.cn",  // China auth endpoint
});

const authProvider = new TokenCredentialAuthenticationProvider(credential, {
  scopes: ["https://microsoftgraph.chinacloudapi.cn/.default"],
});

const client = Client.initWithMiddleware({
  authProvider,
  baseUrl: "https://microsoftgraph.chinacloudapi.cn/v1.0",  // China Graph endpoint
});

// Step 1: Get real folderId (NOT using well-known alias)
const folder = await client.api("/me/mailFolders/inbox").get();
const folderId = folder.id;  // e.g. "AQMkADAwATM0MDAAMS1..."

// ✅ Works fine
const messages = await client
  .api(`/me/mailFolders/${folderId}/messages`)
  .select("id,subject,from,receivedDateTime,isRead,hasAttachments,bodyPreview")
  .top(20)
  .get();

// ❌ Throws ErrorInvalidIdMalformed — same folderId, only added /delta
const delta = await client
  .api(`/me/mailFolders/${folderId}/messages/delta`)
  .select("id,subject,from,receivedDateTime,isRead,hasAttachments,bodyPreview")
  .top(20)
  .get();

Expected Behavior

/me/mailFolders/{folderId}/messages/delta should return a valid delta response (with @odata.deltaLink or @odata.nextLink) using the same folderId that works with the non-delta endpoint.

This behavior already works correctly on the international endpoint (graph.microsoft.com).


Actual Behavior

The delta endpoint returns 400 Bad Request with error code ErrorInvalidIdMalformed on the China (21Vianet) endpoint, even though:

  • ✅ The folderId is a real ID retrieved directly from the Graph API (not a well-known alias)
  • ✅ The same folderId works on /messages (non-delta)
  • ✅ The same delta call works on the international endpoint

Comparison Summary

ScenarioInternational EndpointChina (21Vianet) Endpoint/messages with real folderId✅ 200 OK✅ 200 OK/messages/delta with real folderId✅ 200 OK❌ 400 ErrorInvalidIdMalformed/messages/delta with well-known alias✅ 200 OK❌ 400 ErrorInvalidIdMalformed---

Questions

  1. Is /messages/delta officially supported on the China (21Vianet) endpoint?
  2. If supported, is there a different ID format required specifically for the delta endpoint on the China endpoint?
  3. Is there a known workaround other than falling back to non-delta pagination?
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.