Skip to content

Instantly share code, notes, and snippets.

@curzona
Created April 6, 2014 09:43
Show Gist options
  • Save curzona/10003738 to your computer and use it in GitHub Desktop.
Save curzona/10003738 to your computer and use it in GitHub Desktop.
Disable a TeamCity agent through the REST API in C# http://devnet.jetbrains.com/message/5462246#5462246
string address = "http://<TEAMCITY>/httpAuth/app/rest/agents/id:1/enabled";
byte[] data = Encoding.UTF8.GetBytes("false");
using (var client = new System.Net.WebClient())
{
client.UseDefaultCredentials = true;
client.Credentials = new NetworkCredential("<USER>", "<PASSWORD>");
byte[] response = client.UploadData(address, "PUT", data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment