如何编写一个负责连接到restful api的库? lib应该提供直接访问api函数的方法。正在使用WebClient
以字符串形式获得响应,并且将其作为对象进行反序列化成为可靠的可接受的方式来执行此操作?C#在生产中使用Json WebService
ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true;//the server uses a self signed SSL cert
using (WebClient client = new WebClient())
{
client.Headers.Add("..", "....");
string str = client.DownloadString("https://..../users/"+UserId+"/super-secret-data");
}
谢谢,我已经使用swagger,我不知道我可以用它来自动导入!对不起,我已经写了整个Api连接器。 :d – appl3r