简体   繁体   中英

Mailgun email validation in C#

I am trying to verify an email using a MailgunAPI in C#. My problem is - regardless of whether an email is valid or not, I am still getting response.Content = "{\\"error\\":\\"not found\\"}" And it is really hard to say whether the validation URL is wrong (got it from here ) or the actual email was not found.

var request = new RestRequest();
request.AddParameter("domain", domain, ParameterType.UrlSegment);
request.Method = Method.POST;
request.Resource = "/address/validate";
request.AddParameter("address", item);
var response = client.Execute(request);
dynamic content = JsonConvert.DeserializeObject(response.Content);
if (content.error != null)
{
     Console.Out.WriteLine(content.error);
}

This is because you are making a request using 'POST' method. Switch to 'GET' method. request.Method = Method.GET;

GET requires parameters to be appended to URL string. So, you might need to update the way you are sending in parameters or the RestRequest class might handle that for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM