从OfficeJS加载项进行EWS REST API调用会随机失败

时间:2019-05-15 18:12:15

标签: office-js outlook-web-addins

我们最近切换到在Outlook加载项中使用REST API执行loadAsyncProperties [1]和saveAsync [2]操作,并且遇到了以下行为:

  1. 第一次打开邮件(随机发生)时,restUrl为空

  2. EWS REST端点偶尔返回以下错误:

{
    "error": {
        "code": "ErrorAccessDenied",
        "message": "The api you are trying to access does not support item scoped OAuth."
    }
}
{
    "error": {
        "code": "ErrorAccessDenied",
        "message": "Access is denied. Check credentials and try again."
    }
}
{
    "error": {
        "code": "ErrorItemNotFound",
        "message": "The specified object was not found in the store., The process failed to get the correct properties."
    }
}

再次执行相同的操作时,将返回预期的响应。

  1. getCallbackTokenAsync将随机返回null

为什么这会偶尔发生?

复制步骤

  1. 通过调用restUrl属性获取REST URL
  2. 通过调用getCallbackTokenAsync获取REST令牌
  3. 使用以下请求检索自定义属性
GET https://outlook.office365.com/api/v2.0/me/messages('<message>')?$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String {00020329-0000-0000-C000-000000000046} Name <>')

上下文

我们无法检索自定义属性。

环境

  • 平台[PC台式机,Mac,iOS,Office Online]:Windows,Mac
  • 主机[Excel,Word,PowerPoint等]:Outlook
  • Office版本号:2016
  • 操作系统:Windows 10,Mac

参考

[1] https://docs.microsoft.com/en-us/office/dev/add-ins/reference/objectmodel/requirement-set-1.5/office.context.mailbox.item?view=office-js#loadcustompropertiesasynccallback-usercontext

[2] https://docs.microsoft.com/en-us/office/dev/add-ins/reference/objectmodel/requirement-set-1.5/office.context.mailbox.item?view=office-js#saveasyncoptions-callback

[3] https://docs.microsoft.com/en-us/office/dev/add-ins/reference/objectmodel/requirement-set-1.5/office.context.mailbox?view=office-js#resturl-string

0 个答案:

没有答案