Microsoft Office Add in Javascript,MarkAsJunk请求返回GenericResponseError [英] Microsoft Office Add in Javascript, MarkAsJunk Request returns GenericResponseError

查看:15
本文介绍了Microsoft Office Add in Javascript,MarkAsJunk请求返回GenericResponseError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此API和生成器创建一个javascript Outlook外接程序。https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/apishttps://github.com/OfficeDev/generator-office

由于我希望将特定邮件移到垃圾邮件文件夹,因此我尝试按照以下流程操作。

我可以使用Office.context.mailbox.makeEwsRequestAsync获取信息。

https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/markasjunk-operation https://docs.microsoft.com/en-us/javascript/api/outlook/office.mailbox?view=outlook-js-1.5&preserve-view=true#makeEwsRequestAsync_data__callback__userContext_

然后,我终于尝试标记AsJunk请求,它返回GenericResponseError

我安装外接程序的环境是MS365 Outlook Web应用程序,并且我在Office生成器本地主机dev-server中托管我的外接程序。

以下是代码。

item.itemIdOffice.context.mailbox.item.itemId

changeKey是在代码的另一部分中获取的ChangeKey。

    const request =
     `<?xml version="1.0" encoding="utf-8"?>
     <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                   xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                   xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
            <t:RequestServerVersion Version="Exchange2013" />
        </soap:Header>
        <soap:Body>
            <m:MarkAsJunk IsJunk="true" MoveItem="true">
                <m:ItemIds>
                    <t:ItemId Id="${item.itemId}" ChangeKey="${changeKey}" />
                </m:ItemIds>
            </m:MarkAsJunk>
        </soap:Body>
    </soap:Envelope> `


    Office.context.mailbox.makeEwsRequestAsync(request, (result) => {
        console.log(result);
        console.log(result.error.message)
    })

以下是错误消息

{"status":"failed","error":{"name":"GenericResponseError","message":"The request is invalid.","code":9020}}

我如何才能解决这个问题?是否有需要修复的部分或需要检查的设置? 非常感谢。

error showed in browser

推荐答案

要了解这是否是OfficeJS(makeEwsRequestAsync)的限制,您需要自己使用EWS。由于OfficeJS提供对EWS操作的受限访问,Office Web加载项无法使用/支持某些操作。

尝试使用EWSEditor连接到邮箱并手动运行操作。

这篇关于Microsoft Office Add in Javascript,MarkAsJunk请求返回GenericResponseError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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