最近在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"}'

 

相关文章:

  • 2022-12-23
猜你喜欢
  • 2021-05-20
  • 2022-02-09
  • 2021-07-13
  • 2021-04-19
  • 2022-12-23
  • 2021-08-19
相关资源
相似解决方案