1
我有一个PowerShell脚本,这是否:如何从C#客户端发送修补程序请求?
$uri = "$($tfsUri)/$($teamproject)/_apis/build/builds/$($buildID)?api-version=2.0"
$data = @{keepForever = $keepForever} | ConvertTo-Json
$response = $webclient.UploadString($uri,"PATCH", $data)
我想在C#改写这个,使用Web客户端。
WebClient client = new WebClient();
client.Encoding = System.Text.Encoding.UTF8;
string reply = client.UploadString(url, "keepForever = true");
Console.WriteLine(reply);
但我得到:远程服务器返回一个错误:(401)未经授权。
这是TFS 2015 VNext,如果有帮助的话。