Visual Studio and TeamCity integration

Hi all,

I was wondering if it is possible to trigger a build from c# code in visual studio?

5 comments
Comment actions Permalink

You can make HTTP calls to TeamCity server from external tools

Triggering a Build From Script

0
Comment actions Permalink

Great, I do that now.  But for some or other reason when I put URL in browser the build triggers, but when I do it through HttpWebRequest it doesn't do anything...

Here is my code for HttpWebRequest:

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(@"http://millers/httpAuth/action.html?add2Queue=bt2&name=svn&value=0");
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";

0
Comment actions Permalink

you need to specify credentials in form http://user:password@host/

0
Comment actions Permalink

That is what I also tried...

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(@"http://admin:Coughing@millers/httpAuth/action.html?add2Queue=bt2&name=svn&value=570");
req.GetResponse();

But it returns error:

The remote server returned an error: (401) Unauthorized.

0
Comment actions Permalink

I fixed the problem:

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(@"http://username:password@domain/httpAuth/action.html?add2Queue=bt2&name=svn&value=570");
req.Headers[HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes("username:password"));
req.GetResponse();

0

Please sign in to leave a comment.