找不到 C#、RestSharp、类型或命名空间名称 "HttpBasicAuthenticator"
C#, RestSharp, Type or Namespace name "HttpBasicAuthenticator" could not be found
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
using RestSharp;
namespace ConsoleProgram
{
public class TryingOutRest {
public resttest Execute<resttest>(RestRequest request) where resttest : new() {
var client = new RestClient();
client.BaseUrl = new Uri("http://www.ocrwebservice.com");
client.Authenticator = new HttpBasicAuthenticator("apid", "apikey");
// the key and and id are put in as a string, but i removed them for the purposes of this.
var re_quest = new RestRequest();
re_quest.Resource = "/restservices/processDocument";
var response = client.Execute<resttest>(request);
}
}
}
所以,您好,我正在尝试掌握 Rest api,目前正在做一个涉及它和 OCR 的项目,您可能会说。试过这个,我认为它会工作得很好,但我似乎搞砸了,或者一些命名发生了变化,我在自动填充菜单中找不到任何相关的东西。
任何人都知道发生了什么事?
P.s。如果有关于安装的问题,我使用了 NuGet,所以我认为不会有问题。
尝试
using RestSharp.Authenticators;
现在这似乎是 HttpBasicAuthenticator
的命名空间。 (Github)
打开 Nugetpackage 管理器并安装 RestSharp
然后你可以使用
使用 RestSharp.Authenticators
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
using RestSharp;
namespace ConsoleProgram
{
public class TryingOutRest {
public resttest Execute<resttest>(RestRequest request) where resttest : new() {
var client = new RestClient();
client.BaseUrl = new Uri("http://www.ocrwebservice.com");
client.Authenticator = new HttpBasicAuthenticator("apid", "apikey");
// the key and and id are put in as a string, but i removed them for the purposes of this.
var re_quest = new RestRequest();
re_quest.Resource = "/restservices/processDocument";
var response = client.Execute<resttest>(request);
}
}
}
所以,您好,我正在尝试掌握 Rest api,目前正在做一个涉及它和 OCR 的项目,您可能会说。试过这个,我认为它会工作得很好,但我似乎搞砸了,或者一些命名发生了变化,我在自动填充菜单中找不到任何相关的东西。 任何人都知道发生了什么事? P.s。如果有关于安装的问题,我使用了 NuGet,所以我认为不会有问题。
尝试
using RestSharp.Authenticators;
现在这似乎是 HttpBasicAuthenticator
的命名空间。 (Github)
打开 Nugetpackage 管理器并安装 RestSharp 然后你可以使用 使用 RestSharp.Authenticators