There is a cURL example in section Triggering a Build
of TeamCity 9.x Documentation:
curl -v -u user:password http://teamcity.server.url:8111/app/rest/buildQueue --request POST --header "Content-Type:application/xml" --data-binary @build.xml
I'd like to know how to convert it into an equivalent Python script (using POST
request from the requests
module)?
BTW, I tried the following Python script but got such a response code 400 (Bad Request)
:
url = "http://myteamcity.com:8111/httpAuth/app/rest/buildQueue/"
headers = {'Content-Type': 'application/json'}
data = json.dumps({'buildTypeId': 'MyTestBuild'})
r = requests.post(url, headers=headers, data=data, auth=("username", "password"), timeout=10)
print "r = ", r
>> r = <Response [400]>
If change the Content-Type
in headers
into Accept
, got another response code 415 (Unsupported Media Type)
:
headers = {'Accept': 'application/json'}
>> r = <Response [415]>