我的问题: 使用命令行工具卷曲我的本地主机服务器,同时发送一些数据和我的POST请求不起作用.
似乎导致错误的原因: 想象一下这样的事情
curl -i -X POST -H 'Content-Type: application/json' -d '{"data1": "data goes here", "data2": "data2 goes here"}' http:localhost/path/to/api返回数据的结果
curl: (6) Could not resolve host: application; No data record of requested type
curl: (6) Could not resolve host: data goes here,; No data record of requested type
curl: (6) Could not resolve host: data2; No data record of requested type
curl: (3) [globbing] unmatched close brace/bracket at pos 16
Run Code Online (Sandbox Code Playgroud)
经过一番搜索,我发现问题不能是用于请求的sintax,因为它适用于UNIX shell.
你可能在使用Windows吗?这看起来像一个完全破坏的shell,不能正确处理单引号和双引号.我刚试过那个命令行,它在我的linux机箱上工作正常. http://curl.haxx.se/mail/archive-2011-03/0066.html
我试图解决那些"逃避它"的问题,但它仍然没有奏效
2.
curl -i …