RestSharp 响应未经授权

RestSharp response unauthorized

我不熟悉基于网络的解决方案。我正在使用 RestSharp 库休息 url。
我的代码如下:

var cleint = new RestClient("http://REST_URL");
cleint.Authenticator = new HttpBasicAuthenticator("username", "password");
var request = new RestRequest();
request.Method = Method.GET;
request.Resource = "0.json";

IRestResponse response = cleint.Execute(request);
if (response != null && ((response.StatusCode ==       HttpStatusCode.OK) &&
(response.ResponseStatus == ResponseStatus.Completed)))
  {
  // var arr = JsonConvert.DeserializeObject<JArray>    (response.Content);

  }

urlreturns一个json文件,我手动打的时候。但我想使用 C# 控制台应用程序获取 json 文件并将其保存到磁盘。当我 运行 上面提到的代码时,我收到未经授权的响应:
response.ResponseStatus= "Unauthorized"

这就是它所需要的..

  client.Authenticator = new NtlmAuthenticator();

因此,如果您的 IIS 设置已启用 Windows 身份验证,这就是您需要的,Http 基本身份验证不足以绕过服务器安全