[英]Mac Excel web query not working
We use web queries
to retrieve data in Excel for reporting purpose.我们使用web queries
在 Excel 中检索数据以用于报告目的。 These Web queries are working correctly in Excel 2007, 2010, 2013 and 2016.这些 Web 查询在 Excel 2007、2010、2013 和 2016 中正常工作。
But when used in Mac Excel 2016 it fails .但是在Mac Excel 2016 中使用时它失败了。
We perform these web queries using VBA
and retrieve data generated by a Spring REST
interface.我们使用VBA
执行这些 Web 查询并检索由Spring REST
接口生成的数据。
I already tried using http GET
instead of http POST
and tried performing the web query via the UI ('Data' -> 'Get External Data' -> 'Run Saved Query' using a .iqy
file).我已经尝试使用http GET
而不是http POST
并尝试通过 UI 执行 Web 查询(“数据”->“获取外部数据”->“使用.iqy
文件运行保存的查询”)。
Also error seems not to be content related (tried very simple html; <html><body><table><tr><td>col1</td></tr><tr><td>value1</td></tr></table></body></html>
) .此外,错误似乎与内容无关(尝试了非常简单的 html; <html><body><table><tr><td>col1</td></tr><tr><td>value1</td></tr></table></body></html>
) 。
When using Wireshark to analyze the traffic, the response of the REST call is correct ( http 200
with correct content).使用Wireshark分析流量时,REST调用的响应是正确的( http 200
,内容正确)。
Errors reported using UI import using '.iqy' file: "cannot locate the internet server or proxy server"
.使用“.iqy”文件使用 UI 导入时报告的错误: "cannot locate the internet server or proxy server"
。 Error performing web query using VBA: "Error 1004 Application-defined or Object-defined error"
.使用 VBA 执行 Web 查询时"Error 1004 Application-defined or Object-defined error"
: "Error 1004 Application-defined or Object-defined error"
。
Does anyone have an idea what can cause this behavior?有谁知道是什么导致了这种行为?
Found the reason: Spring MVC (REST) has some default headers it sets.找到原因:Spring MVC (REST) 设置了一些默认标头。 One of them is X-Content-Type-Options: nosniff
.其中之一是X-Content-Type-Options: nosniff
。 The way we generated some of the REST response data, resulted in not setting the Content-Type
header.我们生成一些 REST 响应数据的方式导致没有设置Content-Type
标头。
Mac Excel was not able to determine the content type (because of the X-Content-Type-Options: nosniff option) . Mac Excel 无法确定内容类型(因为 X-Content-Type-Options: nosniff 选项) 。
This can be solved by either not setting the X-Content-Type-Options header or explicitly set the Content-Type
header.这可以通过不设置X-Content-Type-Options标头或显式设置Content-Type
标头来解决。
Bonus info : I've used WireMock to simulate REST interface and was able to strip headers one by one exposing the culprit.额外信息:我使用WireMock来模拟 REST 接口,并且能够一一去除标题,暴露罪魁祸首。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.