Icon

You are viewing the documentation of TeamCity 10.x and 2017.x, which is not the most recently released version of TeamCity.
View this page in the latest documentation or refer to the listing to choose the documentation corresponding to your TeamCity version.

 

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

More examples (for TeamCity 8.0) are available in this external posting.

 

 

Wiki Markup
{hidden-data}

Example C# code shared by our users to do REST API calls with NTLM authentication and cookies reuse:

{noformat}
using System;
using System.IO;
using System.Net;

namespace TestingSingleSignOnAuthREST
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(GetRestResponse("http://teamcity.jetbrains.com", "/app/rest/server"));
            Console.ReadLine();
        }

        public static string GetRestResponse(string server, string requestStr)
        {
            var cookies = new CookieContainer();
            var request = (HttpWebRequest)WebRequest.Create(server + requestStr);
            request.Timeout = (int)TimeSpan.FromDays(1).TotalMilliseconds;
            request.ContentType = "application/xml";
            request.UseDefaultCredentials = true;
            request.PreAuthenticate = true;
            request.CookieContainer = cookies;

            var resp = request.GetResponse() as HttpWebResponse;
            var reader = new StreamReader(resp.GetResponseStream(), );
            return reader.ReadToEnd();
        }
    }
}
{noformat}
{hidden-data}
 

curl

 

Expand
titleExamples: click to expand

 Get the list of changes for a project: http:// teamcity :8111/app/rest/changes?locator= =project:projectId
 
http://teamcity:8111/app/rest/changes?locator=buildType:(id:bt133),sinceChange:(id:24234) - to get all the changes in the build configuration since the change identified by the id.

 

(warning) Note that editing via the TeamCity Web UI will ve disabled for projects created via the REST API

  Base64url

https://confluence.jetbrains.com/display/TCD10/Configuring+VCS+Post-Commit+Hooks+for+TeamCity