If you’re trying to interface with a TeamCity installation via JSON, there’s scant examples of how to form your requests. The (limited) documentation available works exclusively in XML.
I got stuck while trying to trigger a build with a custom property. I was able to add a new build to the queue with a JSON request that looked like:
1 2 3 4 5 |
{ "buildType": { "id": "groupahead_app_EnterpriseBuild" } } |
But failed when trying to add a custom property.
It turns out that even though you’re issuing your requests in JSON, the payload needs to very closely mirror the XML structure. I ended up solving my issue by hitting the API to view a (previously) queued build. It revealed that I needed to structure the properties object in the following way:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
{ "buildType": { "id": "groupahead_app_EnterpriseBuild" }, "properties": { "property": [ { "name": "groupkey", "value": "the_founders" } ] } } |
Yes, it looks weird for a JSON object, but that’s what TeamCity expects.