typesafe / mnailgun

A simple .Net wrapper library for the Mailgun API that allows you to send messages, create web hooks, manage mailboxes, etc. with minimal effort.
Other
35 stars 25 forks source link

Error sending simple mail #23

Closed asherber closed 7 years ago

asherber commented 7 years ago

The following code is throwing an exception: RuntimeBinderException: 'Newtonsoft.Json.Linq.JObject' does not contain a definition for 'id'. The same params work if I hit the API with RestSharp. Am I missing something here?

Using .NET 4.6.2, mnailgun 1.0.0.

Thanks.

var domain = "sandboxxxx.mailgun.org";
var key = "key-328xxx";
var client = new MailgunClient(domain, key, 3);
var msg = new MailMessage()
{
    From = new MailAddress("mailgun@samples.mailgun.org", "Excited User"),
    Subject = "Test of library",
    Body = "This is a test of mnailgun."
};
msg.To.Add("me@gmail.com");  // note: using real address here
client.SendMail(msg);
asherber commented 7 years ago

Some more information: I was running the above code in LinqPad. Despite the exception; the mail still went out; the exception was thrown in parsing the response.

When I created an actual VS console app, I got instead a file load error in JSON.Net. Poking around a little, I found that mnailgun was pulling in JSON.Net 3.5.8, very far from the current 9.0.1. Updating JSON.Net, even updating to 5.0.1, worked just fine in both LinqPad and VS. I would suggest that you might want to update the minimum required JSON.Net version in your NuGet package.

typesafe commented 7 years ago

I've published version 2.0.0 (it also includes other changes) of the package. Feel free to re-open if it's still not working for you.

asherber commented 7 years ago

Thanks. I also forked the repo and am working on adding in support for other API variables (Campaign, Testmode, etc.) as well as a different method of supporting tags and variables. Will send a PR when I'm done.