我正在尝试使用RestSharp编码示例来连接到MailGun。在下面的代码中,请参阅:
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();
答案 0 :(得分:5)
身份验证器与RestClient位于不同的命名空间中,您可能只是在顶部缺少using
语句。你有吗?
using RestSharp;
在它下方添加:
using RestSharp.Authenticators;