2016-03-02 44 views
3

我想使用RestSharp编码示例为了连接到MailGun。在下面的代码,请参阅:什么是错误的HttpBasicAuthenticator

client.Authenticator = new HttpBasicAuthenticator("XXX","key-yyyyyyyyyyyyyyyyyyyyyyy"); 

什么是错的HttpBasicAuthenticator? VisualStudio中说:

严重性代码说明项目文件行错误CS0246类型或 命名空间名称“HttpBasicAuthenticator”找不到(你 缺少using指令或程序集引用?)xTest_MailGun

注意:Visual Studio2015社区; RestSharp 105.2.3

这是代码:

RestClient client = new RestClient(); 
client.BaseUrl = new Uri("https://api.mailgun.net/v3"); 
client.Authenticator = new HttpBasicAuthenticator("XXX","key-yyyyyyyyyy"); 
RestRequest request = new RestRequest(); 

回答

3

验证器是在不同的命名空间比RESTClient实现,你很可能只是缺少在顶部using声明。你有这个吗?

using RestSharp; 

添加这种权利在其下方:

using RestSharp.Authenticators; 
+0

谢谢! 由于某些原因,C#记录的示例太多,它总是缺少要导入的内容以获取某些引用的方法或属性。在官方文档中没有提及任何地方时,最烦人的是。 – ljgww