curl Post Json
$ curl -i -X POST -H "'Content-type':'application/x-www-form-urlencoded', 'charset':'utf-8', 'Accept': 'text/plain'" -d 'json_data={"a":"aaa","b":"bbb","data":[{"c":"ccc","d":"ddd","keywords":[{"e": "eee", "f":"fff", "g":"ggg"}]}]}' url

返回信息:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=02565379F21852B33D0367FB7982FE1C; Path=/; HttpOnly
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked

Date: Tue, 22 Oct 2013 10:48:24 GMT

 

这里想要post Json数据到接口上,需要设置好Header,也就是:'Content-type':'application/x-www-form-urlencoded', 'charset':'utf-8', 'Accept': 'text/plain'。
之前一直认为是设置好Content-Type=application/json即可,但是如果有中文就会遇到需要encode的地方了。

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2021-06-12
  • 2022-02-13
猜你喜欢
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
相关资源
相似解决方案