Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON return from a RESTful Query of TeamCity

Tags:

json

teamcity

As per Teamcity REST API

We can use the following to get XML Data

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

Can we do the same for JSON ?

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

BOTH, return

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

Thus , Content-Type: xml

How can i get JSON Reponse.

like image 964
kamal Avatar asked Aug 05 '12 02:08

kamal


1 Answers

You need to set the Accept header not the Content-type header

curl -v --basic --user USERNAME:PASSWORD --request POST "http://teamcity:8111/httpAuth/app/rest/users/" --data @data.json --header "Accept: application/json"
like image 124
Musa Avatar answered Oct 22 '22 00:10

Musa