我正在做一个outlook插件(目前正在网络上测试),我需要得到一些不可更改的ID,这样我就可以在我们的平台上存储这些邮件的引用。 我读了这个 Outlook团队的巨大反应 并一直在尝试调用 translateExchangeIds,但没有成功。首先,我真的找不到一个文档说明这个端点在REST v2.0 API上确实存在。 我可以看出它确实存在,因为我收到错误信息说,如果我只是改变一下json对象的大写,有效载荷就不符合端点所说的需要。 我目前得到的错误信息是
code: "ErrorAccessDenied" message: "Access is denied. Check credentials and try again."
这似乎很明显,我应该做的是检查我的权限。 我能找到的文档中提到我需要User.ReadBasic。 但这确实不是我定义一个outlook addin的权限。 在我的addin的manifest.xml文件中,我定义了以下权限
<Permissions>ReadWriteMailbox</Permissions>
调用这个端点应该绰绰有余。
const getImmutableId = async () => new Promise<string>((resolve) => {
Office.context.mailbox.getCallbackTokenAsync(
{ isRest: true },
(result: Office.AsyncResult<string>) => {
const headers = new Headers();
headers.append('Authorization', `Bearer ${result.value}`);
headers.append('content-type', 'application/json');
headers.append('data-type', 'json');
headers.append('process-data', 'false');
fetch(`${Office.context.mailbox.restUrl}/v2.0/me/translateExchangeIds`, {
headers,
method: 'POST',
body: JSON.stringify({
InputIds: [
Office.context.mailbox.item.itemId,
],
SourceIdType: 'ewsId',
TargetIdType: 'restImmutableEntryId',
}),
}).then((response: Response) => {
if (response.ok) {
response.json().then((restResponse: {targetId: string, sourceId: string}[]) => {
resolve(restResponse[0].targetId);
});
} else {
// eslint-disable-next-line no-console
console.warn('there was a failire to get an immutable id falling back to mutable rest id');
resolve(Office.context.mailbox.convertToRestId(
Office.context.mailbox.item.itemId, Office.MailboxEnums.RestVersion.v2_0,
));
}
});
},
);
});
任何帮助将是非常感激的。
你读到的StackOverflow帖子(联系)指出,样本代码不完整,因为由 getAccessTokenAsync
API调用缺少了 User.ReadBasic.All
许可证,这是该公司所要求的 translateExchangeIds
REST API。有一个现有的 用户心声帖 关于不可更改的ID。请在那里添加您的声音。在规划过程中,我们会考虑用户意见的功能要求。