N.O*_*sen 4 api rest restsharp visual-studio-2015
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以,嗨,试图掌握Rest api,正在做一个涉及它和OCR的项目,你可能会说.试过这个,我认为它会工作正常,但我似乎已经搞砸了或者某些命名已经改变,我无法在自动填充菜单中找到任何相关内容.任何人都知道发生了什么?如果有关于安装的问题,我使用NuGet,所以我认为没有问题.
尝试
using RestSharp.Authenticators;
Run Code Online (Sandbox Code Playgroud)
这似乎是HttpBasicAuthenticator
现在的命名空间.(Github)