diff --git a/.gitignore b/.gitignore index 2a6854d..2f46584 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,8 @@ target/ build/ gradle.properties .gradle -repo/ \ No newline at end of file +repo/ + +# JetBrains IDEs +*.iml +**/.idea/ diff --git a/src/main/java/com/sendgrid/Client.java b/src/main/java/com/sendgrid/Client.java index 9a0c2f1..6179d7f 100644 --- a/src/main/java/com/sendgrid/Client.java +++ b/src/main/java/com/sendgrid/Client.java @@ -30,6 +30,7 @@ import java.net.URISyntaxException; import java.net.URLEncoder; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -206,13 +207,9 @@ public Response post(Request request) throws URISyntaxException, IOException { } } - try { - httpPost.setEntity(new StringEntity(request.body)); - if (request.body != "") { - httpPost.setHeader("Content-Type", "application/json"); - } - } catch (IOException ex) { - throw ex; + httpPost.setEntity(new StringEntity(request.body, Charset.forName("UTF-8"))); + if (request.body != "") { + httpPost.setHeader("Content-Type", "application/json"); } try { @@ -252,13 +249,9 @@ public Response patch(Request request) throws URISyntaxException, IOException { } } - try { - httpPatch.setEntity(new StringEntity(request.body)); - if (request.body != "") { - httpPatch.setHeader("Content-Type", "application/json"); - } - } catch (IOException ex) { - throw ex; + httpPatch.setEntity(new StringEntity(request.body, Charset.forName("UTF-8"))); + if (request.body != "") { + httpPatch.setHeader("Content-Type", "application/json"); } try { @@ -299,13 +292,9 @@ public Response put(Request request) throws URISyntaxException, IOException { } - try { - httpPut.setEntity(new StringEntity(request.body)); - if (request.body != "") { - httpPut.setHeader("Content-Type", "application/json"); - } - } catch (IOException ex) { - throw ex; + httpPut.setEntity(new StringEntity(request.body, Charset.forName("UTF-8"))); + if (request.body != "") { + httpPut.setHeader("Content-Type", "application/json"); } try { @@ -345,13 +334,9 @@ public Response delete(Request request) throws URISyntaxException, IOException { } } - try { - httpDelete.setEntity(new StringEntity(request.body)); - if (request.body != "") { - httpDelete.setHeader("Content-Type", "application/json"); - } - } catch (IOException ex) { - throw ex; + httpDelete.setEntity(new StringEntity(request.body, Charset.forName("UTF-8"))); + if (request.body != "") { + httpDelete.setHeader("Content-Type", "application/json"); } try {