In the C# tab of the getting started of maingun API, I find the following code.
public static RestResponse SendSimpleMessage() {
RestClient client = new RestClient();
client.BaseUrl = "https://api.mailgun.net/v2";
client.Authenticator =
new HttpBasicAuthenticator("api",
"key-3ax6xnjp29jd6fds4gc373sgvjxteol0");
RestRequest request = new RestRequest();
request.AddParameter("domain",
"samples.mailgun.org", ParameterType.UrlSegment);
request.Resource = "{domain}/messages";
request.AddParameter("from", "Excited User <[email protected]>");
request.AddParameter("to", "[email protected]");
request.AddParameter("to", "[email protected]");
request.AddParameter("subject", "Hello");
request.AddParameter("text", "Testing some Mailgun awesomness!");
request.Method = Method.POST;
return client.Execute(request);
}
When I google the name of the class, I find several reference to this class in different contexts. However, I can't seem to find the fully qualified name of the RestRequest class anywhere on the mailgun website, google or MSDN to find it's documentation.
Anybody can point out where is this class defined ?
If the Apex method has no parameters, then Apex REST copies the HTTP request body into the RestRequest. requestBody property. If there are parameters, then Apex REST attempts to deserialize the data into those parameters and the data won't be deserialized into the RestRequest.
RestContext is a predefined class in apex that consist of request and response context variables. With this, I mean that I can access the whole incoming request by using the request context variable of RestContext class. RestRequest is also a predefined apex class which can be used to create/accept an HTTP request.
The URL mapping is relative to https:// instance . salesforce.com/services/apexrest/. A wildcard character (*) may be used. The URL mapping is case-sensitive. A URL mapping for my_url will only match a REST resource containing my_url and not My_Url .
The code looks like it uses RestSharp.
RestSharp is available from NuGet. Install it from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With