【问题标题】:How to fetch outlook contacts using rest API如何使用 REST API 获取 Outlook 联系人
【发布时间】:2020-09-20 20:09:20
【问题描述】:

我对 Outlook 插件开发非常陌生。对于我的插件,我需要从当前 Outlook 帐户中获取所有联系人。我尝试使用以下代码:

Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function (result) {
                if (result.status === "succeeded") {
                    var accessToken = result.value;
                    console.log("access token", accessToken);
                    getCurrentItem(accessToken);
                } else {
                    // Handle the error.
                }
});
 function getCurrentItem(accessToken) {

        var getcontacts = Office.context.mailbox.restUrl +
            '/v2.0/me/contacts';
        console.log(getcontacts);
        $.ajax({
            url: getcontacts,
            dataType: 'json',
            headers: { 'Authorization': 'Bearer ' + accessToken }
        }).done(function (item) {
            console.log(item);
      }).fail(function (error) {
                    // Handle error.
                });
    }

当我在 Outlook 插件中使用此 js 文件并对其进行安慰时,以 403 禁止错误结束。这个怎么用?我的代码中是否存在错误?

提前致谢!

【问题讨论】:

    标签: outlook office365 outlook-addin outlook-web-addins outlook-restapi


    【解决方案1】:

    找到问题的答案。

    问题是,我的清单 xml 文件中没有授予权限:

      <Permissions>ReadWriteMailbox</Permissions>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 2017-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多