您需要将内容类型设置为application /
json。但是
-d发送Content-Type
application/x-www-form-urlenpred,在Spring方面不接受。
查看curl手册页,我认为您可以使用
-H:
-H "Content-Type: application/json"
完整示例:
curl --header "Content-Type: application/json" --request POST --data '{"username":"xyz","password":"xyz"}' http://localhost:3000/api/login(
-H的缩写
--header,
-d为
--data)
请注意,如果使用,
-request POST则是 可选的
-d,因为该
-d标志表示POST请求。
在Windows上,情况略有不同。请参阅评论主题。



