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)";
You can make HTTP calls to TeamCity server from external tools
Triggering a Build From Script
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)";
you need to specify credentials in form http://user:password@host/
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.
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();