cURL 命令在 Linux 中运行,但不在 Windows 2008 中运行

Ian*_*n M 5 windows-server-2008 curl

我已经在 Windows 2008 Server 上安装了 cURL,并且正在尝试执行下面的命令。此命令在同一 LAN 上的 Ubuntu 机器上执行良好,但是当我在 Windows 中运行它时,出现以下错误:

curl -H "Content-Type: application/json" -X POST -d '{ "entity_id": "switch.study_cam" }' https://192.168.1.99:8123/api/services/switch/turn_off?api_password=MyAPIPassword --insecure
curl: (6) Could not resolve host: entity_id
curl: (6) Could not resolve host: switch.study_cam
curl: (3) [globbing] unmatched close brace/bracket in column 1
{"message": "Data should be valid JSON"}
Run Code Online (Sandbox Code Playgroud)

我已经使用http://www.google.com在 Windows 上测试了 cURL ,它返回了有效的 HTML,因此它似乎已正确安装。

cURL for Windows 和 Linux 之间是否存在语法差异,或者是否有其他解释为什么上述命令在 Windows 中失败?

mvw*_*mvw 3

我会将 JSON 放入一个文件中,例如json.txt,并使用curl -d @json.txt 它来避免 shell 的引用处理问题。

这会给类似的东西

curl -H "Content-Type: application/json" -X POST -d @json.txt \
https://192.168.1.99:8123/api/services/switch\
/turn_off?api_password=MyAPIPassword --insecure
Run Code Online (Sandbox Code Playgroud)

如果您错过了 Unix shell,MSYS2是一个不错的系统,可以将常用的工具组添加到您的 Windows 计算机上(不过它必须比 Windows XP / Windows Server 2003 更新)。