EVE:[globbing] unmatched close brace/bracket in column 6

根據官方教程,在命令行中使用curl執行下面命令:

curl -d '[{"firstname": "barack", "lastname": "obama"}, {"firstname": "mitt", "lastname": "romney"}]' -H 'Content-Type: application/json'  http://127.0.0.1:5000/people

出現瞭如下錯誤:

curl: (6) Could not resolve host: barack,
curl: (6) Could not resolve host: lastname
curl: (3) [globbing] unmatched close brace/bracket in column 6
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: mitt,
curl: (6) Could not resolve host: lastname
curl: (3) [globbing] unmatched close brace/bracket in column 7
curl: (6) Could not resolve host: application
{"_status": "ERR", "_issues": {"'[{firstname:": "unknown field", "lastname": "required field"}, "_error": {"code": 422, "message": "Insertion failure: 1 document(s) contain(s) error(s)"}}

原因是由於我使用的是windows系統,而window的command.exe似乎不支持單引號,所以只要將其中的單引號改爲雙引號,並轉義字符串中的任何雙引號

curl -d "[{\"firstname\": \"barack\", \"lastname\": \"obama\"}, {\"firstname\": \"mitt\", \"lastname\": \"romney\"}]" -H "Content-Type: application/json" http://127.0.0.1:5000/people

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章