user: translateExchangeIds
命名空间:microsoft.graph
对与 Outlook 相关的资源的标识符进行格式转换。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
User.ReadBasic.All、User.Read、User.ReadWrite、User.ReadBasic.All、User.Read.All、User.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
User.ReadBasic.All、User.Read、User.ReadWrite |
| 应用程序 |
User.Read.All、User.ReadWrite.All |
HTTP 请求
POST /me/translateExchangeIds
POST /users/{id|userPrincipalName}/translateExchangeIds
| 名称 |
值 |
| Authorization |
Bearer {token}。必需。 |
请求正文
| 参数 |
类型 |
说明 |
| inputIds |
String 集合 |
要转换的标识符的集合。 集合中所有标识符必须具有相同的源 ID 类型,并且必须为同一邮箱中的项目。 此集合的最大大小为 1000 个字符串。 |
| sourceIdType |
exchangeIdFormat |
参数中标识符的 InputIds ID 类型。 |
| targetIdType |
exchangeIdFormat |
要转换为的请求 ID 类型。 |
| 成员 |
说明 |
| entryId |
MAPI 客户端使用的二进制条目 ID 格式。 |
| ewsId |
Web 服务客户端Exchange ID 格式。 |
| immutableEntryId |
二进制 MAPI 兼容不可变 ID 格式。 |
| restId |
Microsoft Graph 使用的默认 ID Graph。 |
| restImmutableEntryId |
Microsoft Graph 使用的不可变 ID Graph。 |
二进制格式 (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"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var inputIds = new List<String>()
{
"{rest-formatted-id-1}",
"{rest-formatted-id-2}"
};
var sourceIdType = ExchangeIdFormat.RestId;
var targetIdType = ExchangeIdFormat.RestImmutableEntryId;
await graphClient.Me
.TranslateExchangeIds(inputIds,targetIdType,sourceIdType)
.Request()
.PostAsync();
有关如何将 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 文档。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/translateExchangeIds"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSMutableArray *inputIdsList = [[NSMutableArray alloc] init];
[inputIdsList addObject: @"{rest-formatted-id-1}"];
[inputIdsList addObject: @"{rest-formatted-id-2}"];
payloadDictionary[@"inputIds"] = inputIdsList;
MSGraphExchangeIdFormat *sourceIdType = [MSGraphExchangeIdFormat restId];
payloadDictionary[@"sourceIdType"] = sourceIdType;
MSGraphExchangeIdFormat *targetIdType = [MSGraphExchangeIdFormat restImmutableEntryId];
payloadDictionary[@"targetIdType"] = targetIdType;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<String> inputIdsList = new LinkedList<String>();
inputIdsList.add("{rest-formatted-id-1}");
inputIdsList.add("{rest-formatted-id-2}");
ExchangeIdFormat sourceIdType = ExchangeIdFormat.REST_ID;
ExchangeIdFormat targetIdType = ExchangeIdFormat.REST_IMMUTABLE_ENTRY_ID;
graphClient.me()
.translateExchangeIds(UserTranslateExchangeIdsParameterSet
.newBuilder()
.withInputIds(inputIdsList)
.withTargetIdType(targetIdType)
.withSourceIdType(sourceIdType)
.build())
.buildRequest()
.post();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
requestBody.SetInputIds( []String {
"{rest-formatted-id-1}",
"{rest-formatted-id-2}",
}
sourceIdType := "restId"
requestBody.SetSourceIdType(&sourceIdType)
targetIdType := "restImmutableEntryId"
requestBody.SetTargetIdType(&targetIdType)
result, err := graphClient.Me().TranslateExchangeIds().Post(requestBody)
有关如何将 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 文档。
响应
下面是示例响应
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}"
}
]
}