Running cUrl cmd from Win7 doesn't work, but on Linux it does

本小妞迷上赌 提交于 2019-12-19 05:54:11

问题


Like the title says. I'm sending a simple cUrl cmd from Win7 to CouchDB on my Linux box, and it doesn't work. But if I run the same command in Linux, it works. I'm sending this:

curl -X POST 192.168.2.5:5984/test/testdoc -d '{"owner":{"fname":"test","lname":"ing"}}'

From windows, it keeps giving me a "error: bad request, reason:invalid UTF-8 JSON". I can run GET commands from windows just fine, I just can't seem to POST to CouchDB.


回答1:


Unfortunately, the Windows shell (cmd.exe) uses quote marks differently from Mac OSX and Linux.

The simplest fix is to avoid single-quotes and use double quotes, with the double-quotes in the JSON document escaped:

curl -X PUT 192.168.2.5:5984/test/testdoc -d "{\"owner\":{\"fname\":\"test\",\"lname\":\"ing\"}}"
{"ok":true,"id":"testdoc","rev":"1-299729b3cb92a371136cb7331c66644d"}

Another option is to install a different shell such as Bash for Windows: http://win-bash.sourceforge.net/. Then you can follow documentation and do your own experiments more easily.



来源:https://stackoverflow.com/questions/2783827/running-curl-cmd-from-win7-doesnt-work-but-on-linux-it-does

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!