TeamCity JSON API

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:

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:

Yes, ┬áit looks weird for a JSON object, but that’s what TeamCity expects.