从TeamCity的RESTful查询返回JSON

从TeamCity的RESTful查询返回JSON,json,teamcity,Json,Teamcity,依照 我们可以使用以下方法来获取XML数据 curl -v --basic --user USERNAME:PASSWORD --request POST "http://teamcity:8111/httpAuth/app/rest/users/" --data @data.xml --header "Content-Type: application/xml" 我们可以对JSON做同样的事情吗 curl -v --basic --user USERNAME:PASSWORD --requ

依照

我们可以使用以下方法来获取XML数据

curl -v --basic --user USERNAME:PASSWORD --request POST "http://teamcity:8111/httpAuth/app/rest/users/" --data @data.xml --header "Content-Type: application/xml"
我们可以对JSON做同样的事情吗

 curl -v --basic --user USERNAME:PASSWORD --request POST "http://teamcity:8111/httpAuth/app/rest/users/" --data @data.json --header "Content-Type: application/json"
两个,返回

HTTP/1.1 200 OK Date: Sun, 05 Aug 2012 02:18:36 GMT Server: Apache-Coyote/1.1 Pragma: no-cache Expires: Thu, 01 Jan 1970 00:00:00 GMT Cache-Control: no-cache Cache-Control: no-store Content-Type: application/xml HTTP/1.1200ok 日期:2012年8月5日星期日02:18:36 GMT 服务器:ApacheCoote/1.1 Pragma:没有缓存 到期时间:1970年1月1日星期四格林威治标准时间00:00:00 缓存控制:没有缓存 缓存控制:没有存储 内容类型:application/xml 因此,内容类型为:xml


如何获取JSON响应。

您需要设置
接受
标题,而不是
内容类型
标题

curl -v --basic --user USERNAME:PASSWORD --request POST "http://teamcity:8111/httpAuth/app/rest/users/" --data @data.json --header "Accept: application/json"

我收到错误:>Accept:application/json>Content Length:0>Content Type:application/x-www-form-urlencoded