命名空间:microsoft.graph
对与 Outlook 相关的资源的标识符进行格式转换。
此 API 可用于以下国家级云部署。
| 全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
| ✅ |
❌ |
❌ |
✅ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 权限类型 |
最低特权权限 |
更高特权权限 |
| 委派(工作或学校帐户) |
User.ReadBasic.All |
User.Read、User.Read.All、User.ReadWrite、User.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
User.Read |
User.ReadWrite |
| 应用程序 |
不支持。 |
不支持。 |
HTTP 请求
POST /me/translateExchangeIds
POST /users/{id|userPrincipalName}/translateExchangeIds
| 名称 |
值 |
| Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
请求正文
| 参数 |
类型 |
说明 |
| inputIds |
字符串集合 |
要转换的标识符的集合。 集合中的所有标识符必须具有相同的源 ID 类型,并且必须用于同一邮箱中的项目。 此集合的最大大小为 1000 个字符串。 |
| sourceIdType |
exchangeIdFormat |
参数中 InputIds 标识符的 ID 类型。 |
| targetIdType |
exchangeIdFormat |
要转换为的请求 ID 类型。 |
| 成员 |
说明 |
| entryId |
MAPI 客户端使用的二进制条目 ID 格式。 |
| ewsId |
Exchange Web Services 客户端使用的 ID 格式。 |
| immutableEntryId |
二进制 MAPI 兼容的不可变 ID 格式。 |
| restId |
Microsoft Graph 使用的默认 ID 格式。 |
| restImmutableEntryId |
Microsoft Graph 使用的不可变 ID 格式。 |
(entryId 和 immutableEntryId) 的二进制格式均采用 URL 安全 base64 编码。 URL 安全性是通过通过以下方式修改二进制数据的 base64 编码来实现的:
- 将
+ 替换为 -
- 将
/ 替换为 _
- 删除任何尾随填充字符 (
=)
- 在字符串末尾添加一个整数,指示原始 (
0、 1或 2)
响应
如果成功,此方法在 200 OK 响应正文中返回响应代码和 convertIdResult 集合。
示例
下面的示例演示如何将多个标识符从普通 REST API 格式 () restId 转换为 REST 不可变格式 (restImmutableEntryId) 。
请求
下面展示了示例请求。
POST https://graph.microsoft.com/v1.0/me/translateExchangeIds
Content-Type: application/json
{
"inputIds" : [
"{rest-formatted-id-1}",
"{rest-formatted-id-2}"
],
"sourceIdType": "restId",
"targetIdType": "restImmutableEntryId"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Me.TranslateExchangeIds;
using Microsoft.Graph.Models;
var requestBody = new TranslateExchangeIdsPostRequestBody
{
InputIds = new List<string>
{
"{rest-formatted-id-1}",
"{rest-formatted-id-2}",
},
SourceIdType = ExchangeIdFormat.RestId,
TargetIdType = ExchangeIdFormat.RestImmutableEntryId,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.TranslateExchangeIds.PostAsTranslateExchangeIdsPostResponseAsync(requestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewItemTranslateExchangeIdsPostRequestBody()
inputIds := []string {
"{rest-formatted-id-1}",
"{rest-formatted-id-2}",
}
requestBody.SetInputIds(inputIds)
sourceIdType := graphmodels.RESTID_EXCHANGEIDFORMAT
requestBody.SetSourceIdType(&sourceIdType)
targetIdType := graphmodels.RESTIMMUTABLEENTRYID_EXCHANGEIDFORMAT
requestBody.SetTargetIdType(&targetIdType)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
translateExchangeIds, err := graphClient.Me().TranslateExchangeIds().PostAsTranslateExchangeIdsPostResponse(context.Background(), requestBody, nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.users.item.translateexchangeids.TranslateExchangeIdsPostRequestBody translateExchangeIdsPostRequestBody = new com.microsoft.graph.users.item.translateexchangeids.TranslateExchangeIdsPostRequestBody();
LinkedList<String> inputIds = new LinkedList<String>();
inputIds.add("{rest-formatted-id-1}");
inputIds.add("{rest-formatted-id-2}");
translateExchangeIdsPostRequestBody.setInputIds(inputIds);
translateExchangeIdsPostRequestBody.setSourceIdType(ExchangeIdFormat.RestId);
translateExchangeIdsPostRequestBody.setTargetIdType(ExchangeIdFormat.RestImmutableEntryId);
var result = graphClient.me().translateExchangeIds().post(translateExchangeIdsPostRequestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const convertIdResult = {
inputIds: [
'{rest-formatted-id-1}',
'{rest-formatted-id-2}'
],
sourceIdType: 'restId',
targetIdType: 'restImmutableEntryId'
};
await client.api('/me/translateExchangeIds')
.post(convertIdResult);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Users\Item\TranslateExchangeIds\TranslateExchangeIdsPostRequestBody;
use Microsoft\Graph\Generated\Models\ExchangeIdFormat;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TranslateExchangeIdsPostRequestBody();
$requestBody->setInputIds(['{rest-formatted-id-1}', '{rest-formatted-id-2}', ]);
$requestBody->setSourceIdType(new ExchangeIdFormat('restId'));
$requestBody->setTargetIdType(new ExchangeIdFormat('restImmutableEntryId'));
$result = $graphServiceClient->me()->translateExchangeIds()->post($requestBody)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Users.Actions
$params = @{
inputIds = @(
'{rest-formatted-id-1}'
'{rest-formatted-id-2}'
)
sourceIdType = "restId"
targetIdType = "restImmutableEntryId"
}
# A UPN can also be used as -UserId.
Invoke-MgTranslateUserExchangeId -UserId $userId -BodyParameter $params
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.users.item.translate_exchange_ids.translate_exchange_ids_post_request_body import TranslateExchangeIdsPostRequestBody
from msgraph.generated.models.exchange_id_format import ExchangeIdFormat
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TranslateExchangeIdsPostRequestBody(
input_ids = [
"{rest-formatted-id-1}",
"{rest-formatted-id-2}",
],
source_id_type = ExchangeIdFormat.RestId,
target_id_type = ExchangeIdFormat.RestImmutableEntryId,
)
result = await graph_client.me.translate_exchange_ids.post(request_body)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
下面是示例响应
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"sourceId": "{rest-formatted-id-1}",
"targetId": "{rest-immutable-formatted-id-1}"
},
{
"sourceId": "{rest-formatted-id-2}",
"targetId": "{rest-immutable-formatted-id-2}"
}
]
}