无法使用Outlook Rest API在Outlook外接程序中向邮件添加附件 [英] Can't add attachment to message in outlook add-in using Outlook rest API

查看:152
本文介绍了无法使用Outlook Rest API在Outlook外接程序中向邮件添加附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到此从Outlook Web加载项问题,但那里没有附件.

I see this Access to Outlook RestAPI from an Outlook web Add-in question but nothing about attachment there.

我成功通过我的加载项发出了Outlook Rest API请求,请遵循 https://dev.office.com/docs/add-ins/outlook/use-rest-api?product=outlook 本教程.例如,我成功获取了一些消息详细信息),但是我有两个问题:

I success to make outlook rest API request from my add-in follow https://dev.office.com/docs/add-ins/outlook/use-rest-api?product=outlook this tutorial . For example I success to get some message details), but I have 2 problems:

  1. 我无法通过Outlook Rest API调用消息添加附件. 我尝试使用itemId拨打电话,如下所示:

  1. I can't add attachment with outlook rest API call to message. I try to make call with the itemId like here:

https://outlook.office.com/api/v2.0/me/messages/" + itemId +"/attachments

我得到的错误是:

{"error":{"code":"ErrorAccessDenied","message":"The api you are trying to access does not support item scoped OAuth."}}

我尝试更改清单上的权限(ReadWriteMailbox/ReadWriteItem),但无济于事.

I try to change permissions(ReadWriteMailbox/ReadWriteItem) on manifest but nothing help..

  1. 有时调用Office.context.mailbox.getCallbackTokenAsync({isRest:true},function()....函数工作并返回访问令牌,有时返回错误,我也不知道原因. 我有时会收到的错误是:

  1. Sometimes the call of Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function().... function work and return access token and sometimes return error , I don't know also what the reason. The error I get sometimes is:

OSF.DDA.AsyncResult
error:OSF.DDA.Error
status:"failed"

希望你能帮助我,谢谢大家!

Hope you could help me , thanks all!!

推荐答案

在#1上,错误表明您拥有的令牌仅作用于当前项目. REST API无法使用这种令牌来修改附件,因此您会收到该错误.正确执行此 的方法是,在外接程序清单中指定ReadWriteMailbox,然后返回的令牌应该是邮箱范围的令牌.但是,当前桌面Outlook对getCallbackTokenAsync的处理存在一个错误,该错误导致它仍然错误地返回项目范围的令牌.该错误已得到修复,但尚未公开发布更新.

On #1, the error indicates that the token you have is scoped to just the current item. The REST API cannot use this kind of token for modifying attachments, so you get that error. The correct way that this should work is that you specify ReadWriteMailbox in your add-in manifest, and then the token you get back should be a mailbox-scoped token. However, there is currently a bug with desktop Outlook's handling of getCallbackTokenAsync that causes it to incorrectly still return an item-scoped token. That bug has been fixed but the update hasn't been publicly pushed yet.

如果要检查此内容,请将获得的令牌复制并转到 https://jwt.io/.将其粘贴在已编码"框中,然后检查有效负载.如果看到"ver": "Exchange.Callback.V1",则为项目范围的令牌.如果您看到"ver": "Exchange.Callback.V2",它是邮箱范围的邮件.

If you want to check this, copy the token you get back and head over to https://jwt.io/. Paste it in the "Encoded" box and check the payload. If you see "ver": "Exchange.Callback.V1" it's the item-scoped token. If you see "ver": "Exchange.Callback.V2" it's the mailbox-scoped one.

在#2上,我不知道.如果您可以在Outlook客户端计算机上获得Fiddler跟踪以捕获发出令牌请求的加载项,将很有帮助.

On #2, I have no idea. It would be helpful if you could get a Fiddler trace on your Outlook client machine that catches the add-in making the token request.

这篇关于无法使用Outlook Rest API在Outlook外接程序中向邮件添加附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆