最近在cmd中使用curl命令来测试rest api,发现有不少问题,这里记录一下。
\
转义Content-type
要由双引号包括起来比如下边的例子就是正确的格式:
curl -X POST localhost:8080/employees -H "Content-type:application/json" -d "{\"name\": \"Samwise Gamgee\", \"role\": \"gardener\"}"
总的来说,还是用postman来测试rest api方便快捷。
原文:https://www.cnblogs.com/yulinlewis/p/9961188.html