更新时间:2022-10-18 15:33:57
您好Jassim RAahma,
感谢您发布此处。
如果你想使用像HttpClient这样的c#发出REST请求,你可以参考以下链接。
https://www.codeproject.com/Tips/497123/How-to-make-REST-requests-with-Csharp
https://github.com/restsharp/RestSharp
***的问候,
Hi,
I have below code using RestSharp but it's not working on my project due to compatibility issues.
I want to ask how can I change the same to work with HttpClient?
RestClient client = new RestClient(); client.BaseUrl = new Uri("https://api.mailgun.net/v3"); client.Authenticator = new HttpBasicAuthenticator("api", "key-fbd876ed51232f347042d0009d9xxxxxx"); RestRequest request = new RestRequest(); request.AddParameter("domain", "domain.softnames.com", ParameterType.UrlSegment); request.Resource = "{domain}/messages"; request.AddParameter("from", "Excited User <noreply@softnames.com>"); request.AddParameter("to", "uk@softnames.com"); request.AddParameter("subject", "Hello"); request.AddParameter("text", "Testing some Mailgun awesomness! This is all about the text only. Just testing the text of this email."); request.Method = Method.POST; client.Execute(request);
Thanks,
Hi Jassim RAahma,
Thank you for posting here.
If you want to make REST request using c# like HttpClient, you could refer to the following link.
https://www.codeproject.com/Tips/497123/How-to-make-REST-requests-with-Csharp
https://github.com/restsharp/RestSharp
Best Regards,