首页 > 编程语言 > 详细

How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?

时间:2016-05-13 11:28:17      阅读:246      评论:0      收藏:0      [点我收藏+]

参考:http://stackoverflow.com/questions/7172784/how-to-post-json-data-with-curl-from-terminal-commandline-to-test-spring-rest

You need to set your content-type to application/json. But -d sends the Content-Type application/x-www-form-urlencoded, which is not accepted on Spring‘s side.

Looking at the curl man page, I think you can use -H:

-H "Content-Type: application/json"
Full example:

curl -H "Content-Type: application/json" -X POST -d ‘{"username":"xyz","password":"xyz"}‘ http://localhost:3000/api/login

How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?

原文:http://www.cnblogs.com/qike/p/5486947.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!