TeamCity REST API 2020.2 Help

Curl Examples

This article contains REST API examples for curl.

You can use the curl command-line tool to interact with the TeamCity REST API.

Example command:

curl -v --basic --user USERNAME:PASSWORD --request POST "http://<TeamCity URL>:<port>/app/rest/users/" --data @data.xml --header "Content-Type: application/xml"

where USERNAME, PASSWORD, <TeamCity URL>:<port> are to be substituted with real values, and data.xml file contains the data to send to the server.

Creating a new project

Using curl tool:

curl -v -u USER:PASSWORD http://<TeamCity URL>:<port>/app/rest/projects --header "Content-Type: application/xml" --data-binary "<newProjectDescription name='New Project Name' id='newProjectId'><parentProject locator='id:project1'/></newProjectDescription>"

Making user a system administrator

  1. Get super user token.

  2. Issue the request.

  3. Get curl command line tool and use a command line:

curl -v -u :SUPERUSER_TOKEN --request PUT http://<TeamCity URL>:<port>/app/rest/users/username:USERNAME/roles/SYSTEM_ADMIN/g/

where SUPERUSER_TOKEN is the super user token unique for each server start; <TeamCity URL>:<port> – the TeamCity server URL; USERNAME – the username of the user to be made the system administrator.

Last modified: 21 December 2020