Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
SendGrid StackMob - Build URL and POST
//Encode any parameters that need encoding (i.e. subject, toname, text)
try {
subject = URLEncoder.encode(subject, "UTF-8");
text = URLEncoder.encode(text, "UTF-8");
toname = URLEncoder.encode(toname, "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.error(e.getMessage(), e);
}
String queryParams = "api_user=" + API_USER + "&api_key=" + API_KEY + "&to=" + to + "&toname=" + toname + "&subject=" + subject + "&text=" + text + "&from=" + from;
url = "https://www.sendgrid.com/api/mail.send.json?" + queryParams;
Header accept = new Header("Accept-Charset", "utf-8");
Header content = new Header("Content-Type", "application/x-www-form-urlencoded");
Set<Header> set = new HashSet();
set.add(accept);
set.add(content);
try {
HttpService http = serviceProvider.getHttpService();
PostRequest req = new PostRequest(url,set,body);
HttpResponse resp = http.post(req);
responseCode = resp.getCode();
responseBody = resp.getBody();
} catch(TimeoutException e) {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.