Linux和Windows下使用curl命令格式差异

编程知识 更新时间:2023-04-06 21:50:51

问题:

linux下使用curl命令成功,在window下使用却报错:

400 Bad Request: Failed to decode JSON object: Expecting value: line 1

解决方法:

由于单引号在Linux和Windows的含义不同,curl调用格式也略有差异。Windows下双引号內部使用双引号需要"\"转义。

Linux下curl格式:

curl -d '{"auth_url": "http://IP:5000/v2.0","user": "user_name","key": "password","tenant_name": "tenantname"}' -H "Content-Type: application/json" -X POST  http://IP:5000/swift/api/v1.0/token

Windows下curl格式:

curl -d "{\"auth_url\": \"http://IP:5000/v2.0\",\"user\": \"user_name\",\"key\": \"password\",\"tenant_name\": \"tenantname\"}" -H "Content-Type: application/json" -X POST  http://IP:5000/swift/api/v1.0/token

更多推荐

Linux和Windows下使用curl命令格式差异

本文发布于:2023-04-06 21:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/79cf6af6c8f2c146224b0b7b22c68027.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:差异   命令   格式   Linux   Windows

发布评论

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

>www.elefans.com

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

  • 50974文章数
  • 14阅读数
  • 0评论数