An API that connects multiple Microsoft services, enabling data access and automation across platforms
/mailFolders/{folderId}/messages/delta returns ErrorInvalidIdMalformed in Microsoft Graph API (China - 21Vianet) while the same folderId works fine with /messages
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
folderIdis a real ID retrieved directly from the Graph API (not a well-known alias) - ✅ The same
folderIdworks 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
- Is
/messages/deltaofficially supported on the China (21Vianet) endpoint? - If supported, is there a different ID format required specifically for the delta endpoint on the China endpoint?
- Is there a known workaround other than falling back to non-delta pagination?