Ну, я создал свою собственную активность клиента REST.Я уверен, что у него есть некоторые ошибки, но он работает для меня.
using System;
using System.Activities;
using System.Net;
using Microsoft.TeamFoundation.Build.Client;
namespace Custom.BuildActivities
{
[BuildExtension(HostEnvironmentOption.Agent)]
[BuildActivity(HostEnvironmentOption.All)]
public sealed class RESTClient : CodeActivity
{
public InArgument<Uri> Url { get; set; }
public InArgument<string> Verb { get; set; }
public OutArgument<HttpStatusCode> StatusCode { get; set; }
public OutArgument<string> ErrorMessage { get; set; }
protected override void Execute(CodeActivityContext context)
{
try
{
Uri url = context.GetValue(this.Url);
string verb = context.GetValue(this.Verb);
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = verb;
HttpWebResponse response = null;
try
{
response = request.GetResponse() as HttpWebResponse;
context.SetValue(this.StatusCode, response.StatusCode);
}
catch (WebException webEx)
{
if (webEx.Response != null)
{
context.SetValue(this.StatusCode, ((HttpWebResponse)webEx.Response).StatusCode);
}
else
{
context.SetValue(this.StatusCode, HttpStatusCode.BadRequest);
}
}
}
catch (Exception ex)
{
context.SetValue(this.ErrorMessage, ex.ToString());
}
}
}
}