码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2016-05-13 11:29:46      阅读:228      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!