Javascript 使用EWS请求获取包含内容的附件内容(文件)

Javascript 使用EWS请求获取包含内容的附件内容(文件),javascript,outlook-web-addins,Javascript,Outlook Web Addins,按照以下链接中的说明,尝试使用EWS请求获取outlook web加载项(Office 365)中邮件项目的附件内容(文件): 已成功获取附件ID,但在将这些附件ID传递到GetAttachment请求信封时,它失败并返回以下响应: {“value”:null,“status”:“failed”,“error”:{“name”:“GenericResponseError”,“message”:“请求的web方法对此调用方或应用程序不可用。”,“code”:9020} function getA

按照以下链接中的说明,尝试使用EWS请求获取outlook web加载项(Office 365)中邮件项目的附件内容(文件):

已成功获取附件ID,但在将这些附件ID传递到GetAttachment请求信封时,它失败并返回以下响应: {“value”:null,“status”:“failed”,“error”:{“name”:“GenericResponseError”,“message”:“请求的web方法对此调用方或应用程序不可用。”,“code”:9020}

function getAttachmentsByAttachmentId(attachmentId){
var requestEnvelopStr = '<?xml version="1.0" encoding="utf-8" ?>';
requestEnvelopStr += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">';
requestEnvelopStr += '<soap:Header>';
requestEnvelopStr += '<t:RequestServerVersion Version="Exchange2010" />';
requestEnvelopStr += '</soap:Header>';
requestEnvelopStr += '<soap:Body>';
requestEnvelopStr += '<m:GetAttachment>';
requestEnvelopStr += '<m:AttachmentIds>';
requestEnvelopStr += '<t:AttachmentId Id="' + attachmentId+'" />';
requestEnvelopStr += '</m:AttachmentIds>';
requestEnvelopStr += '</m:GetAttachment>';
requestEnvelopStr += '</soap:Body>';
requestEnvelopStr += '</soap:Envelope>';
console.log("Before Calling EWS...");
//Calling EWS

Office.context.mailbox.makeEwsRequestAsync(requestEnvelopStr, attachmentsCallBack);
}

function attachmentsCallBack(asyncResultAttachments) {
console.log("asyncResultAttachments.value = " + JSON.stringify(asyncResultAttachments));
}
函数getAttachmentsByAttachmentId(attachmentId){ var-str=''; str+=''; str+=''; str+=''; str+=''; str+=''; str+=''; str+=''; str+=''; str+=''; str+=''; str+=''; str+=''; log(“在调用EWS之前…”); //呼叫EWS Office.context.mailbox.makeEwsRequestAsync(RequestEnvelopestr,attachmentsCallBack); } 函数附件ScalBack(asyncResultAttachments){ log(“asyncResultAttachments.value=“+JSON.stringify(asyncResultAttachments)); }
这是设计的。加载项不支持通过EWS获取附件内容。可以找到受支持的API列表。一个潜在的解决方案是使用我们的预览API之一。请记住,由于API处于预览状态,所以在作为需求集的一部分发布之前,它可能容易出现错误。另一种解决方案是让后端调用以检索附件内容。

您的附件是否需要转义?您还可以在执行此请求时签出Fiddler,它将捕获Outlook API在幕后执行的请求,并查看请求格式和响应头/正文。有时,响应标题中会出现其他错误信息。我们正在从后端获取附件内容,方法是将
attachmentToken
ewsUrl
和所有必需字段从加载项发送到后端。出于某种原因,我们现在得到的JSON响应没有附件内容。你能帮我解答这个问题吗?这听起来像是一个新问题,你能帮我写一篇新的帖子,详细介绍你的后台正在提出的请求和你得到的回复吗?嗨。对不起,这是我的队友造成的错误。一切都好。谢谢你的回复。