curl在windows下和linux中使用的一个区别

  最近在windows环境下的cmd中,使用curl测试post接口,总是报Failed to decode JSON object的错误。

 

  同样的命令在windows环境的git bash窗口中执行是好的。git bash可以模拟linux环境下一些命令的输入效果。  特别是scp命令给linux上传文件,或者从linux上下载文件件时很方便。 

 

  windows环境中,curl命令中的双引号需要使用"\"来进行转义。

  例如,curl -v 127.0.0.1://test/pools -X POST -H "Content-Type: application/json"   -d  '{"message":"test"}'

  要加上转义:

  curl -v 127.0.0.1://test/pools -X POST -H "Content-Type: application/json"   -d  '{\"message\":\"tes\t"}'

 

posted on 2020-11-01 21:46  lnlvinso  阅读(1598)  评论(0编辑  收藏  举报