从Outlook加载项中获取HTTP
我需要调用一个外部web服务,以便我的外接程序与我们公司的Java servlet通信。我尝试使用JavaScript的从Outlook加载项中获取HTTP,outlook,fetch,outlook-addin,Outlook,Fetch,Outlook Addin,我需要调用一个外部web服务,以便我的外接程序与我们公司的Java servlet通信。我尝试使用JavaScript的XMLHttpRequest: var http = new XMLHttpRequest(); http.open( "GET", url2, true ); http.onreadystatechange = function(){ console.log( 'Data: ' + http.responseText + '\nStatus: ' + http.sta
XMLHttpRequest
:
var http = new XMLHttpRequest();
http.open( "GET", url2, true );
http.onreadystatechange = function(){
console.log( 'Data: ' + http.responseText + '\nStatus: ' + http.status );
}
并将谷歌的主要网站指定为白名单:
<AppDomains>
<AppDomain>https://www.google.com/</AppDomain>
</AppDomains>
我搜索了如何专门为Outlook加载项发出跨源HTTP请求,并找到了,因为它的名称与我需要的非常相似,但只找到了有关如何与Outlook本身交互的信息(创建文件夹、标记为垃圾邮件等)
例如,我如何从我的外接程序发出一个简单的请求来获取响应
非常感谢你 你的方向确实是对的。要从第三方web服务检索信息,您需要:
- 使用
或XMLHttpRequest
等发出请求$ajax
- 将服务URL添加到清单的
列表中AppDomains
- 仅使用SSL连接下的服务(
)https://
https://www.google.es
未在您的AppDomains
列表下声明。服务本身可能无法提供任何信息,您可能会得到403
响应。该服务可能不允许CORS
请求,或者在特定授权下通过令牌、许可证等允许该服务。以下来源可能有助于您了解有关该主题的更多信息:
Failed to load https://www.google.com/: Redirect from 'https://www.google.com/' to
'https://www.google.es/?gfe_rd=cr&dcr=0&ei=TFjDWub9No-aX5TXg7AK' has been blocked
by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'https://localhost:3000' is therefore not allowed access.
Data: attachmentsSelectionScreen.html?recordName=A:223
Status: 0