You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The latest version of RestSharp is v107. It's a major upgrade, which contains quite a few breaking changes.
The most important change is that RestSharp stop using the legacy HttpWebRequest class, and uses well-known 'HttpClient' instead. This move solves lots of issues, like hanging connections due to improper HttpClient instance cache, updated protocols support, and many other problems.
Another big change is that SimpleJson is retired completely from the code base. Instead, RestSharp uses JsonSerializer from the System.Text.Json package, which is the default serializer for ASP.NET Core.
Using code with RestSharp latest stable via NuGet (link):
Updated code for v107:
usingRestSharp;usingRestSharp.Authenticators;usingSystem;usingSystem.Threading.Tasks;publicclassSendSimpleMessageChunk{publicstaticvoidMain(string[]args){Console.WriteLine(SendSimpleMessage().Result.Content);Console.ReadLine();}publicasyncstaticTask<RestResponse>SendSimpleMessage(){RestClientOptionsoptions=newRestClientOptions(newUri("https://api.mailgun.net/v3"));RestClientclient=newRestClient(options);client.Authenticator=newHttpBasicAuthenticator("api","YOUR_API_KEY");RestRequestrequest=newRestRequest();request.AddParameter("domain","YOUR_DOMAIN_NAME",ParameterType.UrlSegment);request.Resource="{domain}/messages";request.AddParameter("from","Excited User <mailgun@YOUR_DOMAIN_NAME>");request.AddParameter("to","[email protected]");request.AddParameter("to","YOU@YOUR_DOMAIN_NAME");request.AddParameter("subject","Hello");request.AddParameter("text","Testing some Mailgun awesomness!");request.Method=Method.Post;returnawaitclient.ExecuteAsync(request);}}
The text was updated successfully, but these errors were encountered:
The C# documentation is using an old version of RestSharp, and the code given in examples will not function for the current stable NuGet install.
From https://restsharp.dev/v107/#restsharp-v107:
MailGun Docs (link):
Using code with RestSharp latest stable via NuGet (link):
Updated code for v107:
The text was updated successfully, but these errors were encountered: