Mac Excel网络查询无法正常工作(Mac Excel web query not working)

编程入门 行业动态 更新时间:2024-10-16 16:37:55
Mac Excel网络查询无法正常工作(Mac Excel web query not working)

我们使用web queries来检索Excel中的数据以进行报告。 这些Web查询在Excel 2007,2010,2013和2016中正常运行。 但是,当在Mac Excel 2016中使用时, 它会失败

我们使用VBA执行这些Web查询并检索由Spring REST接口生成的数据。

我已经尝试使用http GET而不是http POST并尝试通过UI('Data' - >'Get External Data' - >'使用.iqy文件运行保存的查询')执行Web查询。 也错误似乎不是内容相关(尝试非常简单的HTML; <html><body><table><tr><td>col1</td></tr><tr><td>value1</td></tr></table></body></html> )

使用Wireshark分析流量时,REST调用的响应是正确的( http 200具有正确的内容)。

使用'.iqy'文件使用UI导入报告错误: "cannot locate the internet server or proxy server" 。 使用VBA执行Web查询时"Error 1004 Application-defined or Object-defined error" : "Error 1004 Application-defined or Object-defined error" 。

有没有人有一个想法是什么会导致这种行为?

We use web queries to retrieve data in Excel for reporting purpose. These Web queries are working correctly in Excel 2007, 2010, 2013 and 2016. But when used in Mac Excel 2016 it fails.

We perform these web queries using VBA and retrieve data generated by a Spring REST interface.

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). 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>).

When using Wireshark to analyze the traffic, the response of the REST call is correct (http 200 with correct content).

Errors reported using UI import using '.iqy' file: "cannot locate the internet server or proxy server". Error performing web query using VBA: "Error 1004 Application-defined or Object-defined error".

Does anyone have an idea what can cause this behavior?

最满意答案

找到原因:Spring MVC(REST)有一些默认的头文件 。 其中之一是X-Content-Type-Options: nosniff 。 我们生成一些REST响应数据的方式导致不设置Content-Type标头。

Mac Excel无法确定内容类型(因为X-Content-Type-Options:nosniff选项)

这可以通过不设置X-Content-Type-Options标题或明确设置Content-Type标题来解决。

奖励信息 :我使用WireMock来模拟REST接口,并且能够逐个剥开标题,揭露罪魁祸首。

Found the reason: Spring MVC (REST) has some default headers it sets. One of them is X-Content-Type-Options: nosniff. The way we generated some of the REST response data, resulted in not setting the Content-Type header.

Mac Excel was not able to determine the content type (because of the X-Content-Type-Options: nosniff option).

This can be solved by either not setting the X-Content-Type-Options header or explicitly set the Content-Type header.

Bonus info: I've used WireMock to simulate REST interface and was able to strip headers one by one exposing the culprit.

更多推荐

本文发布于:2023-08-01 21:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1365814.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   工作   网络   Excel   Mac

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!