sendgrid / java-http-client Goto Github PK
View Code? Open in Web Editor NEWSendGrid's Java HTTP Client for calling APIs
Home Page: https://sendgrid.com
License: MIT License
SendGrid's Java HTTP Client for calling APIs
Home Page: https://sendgrid.com
License: MIT License
When debugging, it can be useful to examine the request body before sending to the SendGrid API.
Prove an example of how to examine the request body in TROUBLESHOOTING.md. For an example, see here.
These public Response variables should be private and accessible via getters/setters: https://github.com/sendgrid/java-http-client/blob/master/src/main/java/com/sendgrid/Response.java#L9
The role of Developer Experience Engineer just became available and we want to announce it in the README. Here is the copy:
If you're a software engineer who is passionate about #DeveloperExperience and/or #OpenSource, this is an incredible opportunity to join our #DX team as a Developer Experience Engineer and work with @thinkingserious and @aroach! Tell your friends :)
Similar to what was done on the SendGrid node README:
![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)
For the following, make sure the correct repo is linked!
For email notifications, you can change the "nodejs" to the language of this repo (e.g. java, python, ruby, php, csharp, go, etc)
[![BuildStatus](https://travis-ci.org/sendgrid/sendgrid-nodejs.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-nodejs)
[![Email Notifications Badge](https://dx.sendgrid.com/badge/nodejs)](https://dx.sendgrid.com/newsletter/nodejs)
[![npm](https://img.shields.io/npm/l/express.svg)]()
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-nodejs.svg)](https://github.com/sendgrid/sendgrid-nodejs/graphs/contributors)
Thank you and happy #Hacktoberfest!!
When travis is running, it is failing during the call to gradlew because of a faulty JAVA_HOME variable. please see the builds here: #27
Borrow the file from sendgrid-java and modify it to fit this repo!
Please make sure you show how to output the SMTPAPI header
In the CONTRIBUTING.md
file there is a section on Style Guidelines & Naming Conventions. Please review and implement a check in Travis CI. If there are any style errors, either fix or create a rule to exclude the error.
Before writing any code, we suggest you review our CONTRIBUTING.md
file and propose your solution for discussion here in the comments. Thank you!
CONTRIBUTING.md
fileWhen I was sending mail with Japanese multi-byte character via sendgrid-java v3.0.2, the received mail contents got garbled.Ex. こんにちは -> ?????
Pretty similar #4 but this is not sending but receiving.
Following simple code.
SendGrid sg = new SendGrid("api keys");
Request request = new Request();
Email from = new Email("[email protected]");
String subject = "こんにちは";
Email to = new Email("[email protected]");
Content content = new Content("text/plain", "こんにちは");
Mail mail = new Mail(from, subject, to, content);
request.method = Method.POST;
request.endpoint = "mail/send";
request.body = mail.build();
Response response = sg.api(request);
I tried curl command with multi-byte, it worked fine. The result means issue on library side.
Our open sourced documentation has a great first time contributor page that we wish to duplicate here.
When all tests on the master branch pass in Travis CI, we would like to auto-deploy the release to the package manager.
Before writing any code, we suggest you review our CONTRIBUTING.md
file and propose your solution for discussion here in the comments. Thank you!
CHANGELOG.md
This license file might have the wrong end year (2017). If this is the case, please make a PR that updates the year. If the year is correct, please close this issue!
In The Client you use BasicResponseHandler to handle the response.
The problem is that when the status code is >= 300 HttpResponseException is thrown, ignoring the response body.
In Sendgrid v3 web API all the details of the failure are in the response body.
so when there is a failure, you have no information about what caused the problem.
You should either insert the response body to the exception message or return your Response even if the status code is >=300 (I think the second option is better).
While creating Response
object the library puts all headers in java.util.HashMap
which is case-sensitive (see: https://github.com/sendgrid/java-http-client/blob/main/src/main/java/com/sendgrid/Client.java#L163). It works fine when nothing messes up with headers. But when, for example, Istio sidecar is running along the application that uses SendGrid envoy proxy lower-cases all HTTP headers (e.g. X-Message-Id
becomes x-message-id
). In order to keep things working one has to manually write logic for looking both X-Message-Id
and x-message-id
which is rather inconvenient. Having headers stored in something like java.util.TreeMap
with String.CASE_INSENSITIVE_ORDER
comparator would make work with headers much easier.
Run SendGrid application along with something that manipulates headers (e.g. makes all of them lower-case).
SendGrid doesn't work on android Level 23+ because HttpClient of Apache which one java-http-client has based on, has been removed from Android 6.
Details of error :
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes3.dex)
We would like to get our English polished up throughout the repo.
These values should be configurable
.setSocketTimeout(timeout)
.setConnectTimeout(timeout)
.setConnectionRequestTimeout(timeout)
Identical blocks of code found in 5 locations. Consider refactoring.
Heads up! This may end up conflicting with #71
This repo should have the following list of files included:
This PR is only asking for tests of the existence of these files, if the files do not exist when you run the tests - do not worry about the tests not passing. We will identify this and create a new PR for the issue.
Thank you!
The Sendgrid Java Http Client dependency on version 1.10.19 of mockito-core leads to the following warning when running a Scala project using JDK 9:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.mockito.cglib.core.ReflectUtils$2 (file:/home/petrova/.ivy2/cache/org.mockito/mockito-core/jars/mockito-core-1.10.19.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.mockito.cglib.core.ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
I assume pure Java 9 projects would have a similar issue.
As mentioned in this issue, the warning can be avoided by upgrading to mockito version 2.13.0.
Expectations: Not to see the warning.
sendgrid-java
, which has not yet upgraded to 4.2.0). (I can also open up an issue over there if that is helpful).Let me know if there is any other information I can provide which would be useful!
There is a gradle error when running against OpenJDK7 in TravisCI.
Specifically the error is:
The command "eval ./gradlew assemble " failed 3 times.
The end year in the license file should be "this year" and this should be checked on every run of the tests. If the end year is no correct, fail the test.
example:
Copyright (c) 2012-2016 SendGrid, Inc.
It is 2017, so this should be:
Copyright (c) 2012-2017 SendGrid, Inc.
and the test should fail.
--done
Our preference is that users have an environment file when using the SendGrid API, because it is less likely that someone would commit their credentials to github.
Please make a couple changes:
export SENDGRID_API_KEY=''
.env
Issue Summary
Add these entries to the .travis.yml file so codecov reports show up!
https://github.com/codecov/example-java/blob/master/.travis.yml
Add a file to the root of this repo called CODE_OF_CONDUCT.md, with the content from the same file in our docs repo.
For every release, we hand craft the release notes on GitHub, now we would like to automate this process. Please see the existing release notes for an example. The contents of the release notes are generated from the CHANGELOG.md file. Here is the documentation for updating the release notes via the GitHub API.
Sendgrid API v3 Reference for categories/stats endpoints states that API call can be made to get stats for upto 10 categories.
However, it does not provide any reference for how to make that API call. I checked the code for addQueryParam here
https://github.com/sendgrid/java-http-client/blob/main/src/main/java/com/sendgrid/Request.java
which takes categories as only key-value pair. How are we supposed to pass "upto 10 categories"?
# paste code here
request.setMethod(Method.GET);
request.setEndpoint("categories/stats");
request.addQueryParam("categories", "qa2"); //how to pass multiple categories here
### Exception/Log
### Technical details:
* java-http-client version: Sendgrid 4.6.4
* java version: JDK 14
For every release, we currently hand craft a CHANGELOG.md update, now we would like to automate this process. Please see the existing CHANGELOG.md for formatting structure.
Although java-http-client compiles just fine with the Java 11 JDK, maven is unable to run the test command because of a dependency on an inappropriate version of the jacoco-maven-plugin. Bringing this dependency current will allow testing on Java 11 as well as all previous JDKs.
mvn test
I expect to be able to compile and test java-http-client no matter what version of the JDK is used.
Clicking on the License badge or license link at the bottom from README.md
gives 404 error
.
Click on license badge or license link from README.md
LICENSE file was renamed to LICENSE.md
from LICENSE.txt
Usage files are really nice when they exist in a repo, because it makes it really obvious where to look for information about how to use this tool. It can be frustrating when you expect this file to be there and it's not.
Please add a USAGE.md file, you can see an example of this
here
Please make sure you modify the file for this repo (hint: Most of this information should be in the README file)
We received an awesome PR for #hacktoberfest on our ruby library
We would love to see the same thing on the README in this repo as well.
Please replace the "-" with "_" in README, CONTRIBUTING, USE_CASES, USAGE files.
Thanks and happy Hacktoberfest!!
Because sendgrid/java-http-client depends on org.apache.httpcomponents/httpcore, this library is necessary under google appengine in order to stay under socket connection quotas:
https://github.com/sendgrid/sendgrid-google-java
But it looks like that library is soon to be very out of date with the latest sendgrid apis. It would be great if java-http-client could remove that dependency and just use the built in java http connection apis directly so that the official sendgrid-java library would work in all scenarios.
java-http-client 4.1.0 currently depends on org.apache.httpcomponents:httpcore:4.4.4, upgrade this to 4.4.12. It also depends on org.apache.httpcomponents:httpclient:4.5.2, upgrade this to 4.5.10.
This reduces enforcer violations when combined with any of the popular libraries that also depend upon httpcomponents (e.g., aws-java-sdk), and makes it easier to compile/use with Java 11.
If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, Github has some great information on how to review a Pull Request.
Due to the success we have seen from hacktoberfest, we are seeing more people create use cases. This is amazing!
We want to make sure that everyone can find them. Please help us to break up this file and make it easier to read and manage:
In the Request we have:
public Map<String,String> headers;
public Map<String,String> queryParams;
set to null when the object gets instantiated.
This could definitely cause JAVA developer errors as they might assume the headers map to be at least instantiated and empty.
In fact in this example:
Map<String,String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("Authorization", "Bearer YOUR_API_KEY");
request.headers = requestHeaders;
The user is forced to instantiate a new one and assign it while the developer could simply:
request.headers.put("Authorization","Bearer YOUR_API_KEY");
When playing with beans (such as Request), if you can avoid referencing externally complex objects it is better. In fact, I would suggest you to turn them private (or protected), add getters and setters, initialize them, and even make them final.
We would like to have a template for describing what has changed in the pull request being submitted.
You can use this file as an example
It is possible to configure how CodeClimate looks at a repository.
These Docs explain how this is done. Please create an appropriate .codeclimate.yml for this repo. It should test the main language of the repo and run tests.
We want to update our git workflow to function more like Gitflow. We need to update the CONTRIBUTING.md file and PULL_REQUEST_TEMPLATE to direct contributors to fork/branch off the development
branch and to merge their PRs with the development
branch. Once this issue is complete, we will be creating the development
branch and making that branch the default. This is part of a larger strategy to execute releases for this SDK on a predictable cadence.
development
branch and submitting PRs agains the development
branch.I am new to SendGrid, I wanted to send a mail with attachment having Norwegian characters in the name. Receiver is receiving the mail but the name contains Å instead of Ø. Saw the Client class , it contains the change for UTF characters
sendgrid-java v3.1.0 is being used. Not using the java-http-client. I visited few related issues but was not able to get which api version include this change. Its urgent for me as we are going in production in two weeks.
Please help!
The current build.gradle configuration specifies mockito-core has a runtime dependency as opposed to the pom.xml which includes it as a test dependency.
You seem to be using Gradle for publishing since the current 4.0.0 version dependency tree has mockito-core scoped to runtime.
Is this expected or should it be scoped to test?
I am getting
java.lang.ClassNotFoundException: Didn't find class "org.apache.http.impl.client.HttpClients"
Please help !
I try to use the sendgrid template and I set the personalization, but one value like this : "Irène" this is word using utf-8 charset. I have set headers
requestHeaders.put("Content-Type", "application/json; charset=utf-8");
request.headers = requestHeaders;
But the return is : org.apache.http.client.HttpResponseException: Unsupported Media Type
I use sendgrid 2.2.2 is ok.
So I check the client.java and find you set the
content_type : "application/json" when the body is not null.
Could you check the headers if there exists the content_type, don't set the content-type automatically?
or you tell me how to sovle this problem ?
Thank you.
Method main
has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Hacktoberfest 2017 has completely blown us away. We have had over 900 pull requests from over 300 contributors all in the last 30 days. That is more PRs than we normally get in 2 years!
We are actively working to review, comment, and/or merge as many PRs as we possibly can as quickly as we can.
We are currently working on “intaking” all the PRs that have come in, oldest first (we have about 400 remaining to go through). We are making sure that each PR we review is one we have a chance of merging - there have been a couple spammy items that came through. Due to the massive influx of requests so far, @thinkingserious and @mbernier have been working nights and weekends all month just to keep up! We’re not even mad, this is amazing!
If you have signed the CLA before 11/1, but haven’t had a PR merged yet, do not despair! We know we are behind on even just commenting on every PR to show you that we received it (something we typically do). If you submitted a mergeable (non-spam, actually adds value to the project) PR during October 2017, we will grant access to this page to redeem your shirt, sticker, and hacker pin. Next year, we will be sure to communicate this information sooner. We are sorry for any confusion we have caused. We appreciate those of you who have reached out to find out what’s going on!
Have you signed the CLA yet?
We can only merge items from contributors who signed the CLA
Can you help another contributor?
If you can identify potential problems, add suggestions, or even leave a comment with your review of another PR (Looks good to me! Or I approve this change), that would help us review those PRs much faster, making it easier to get to your PR.
Do you even write tests, friend?
If you see a place where we could have a test to validate a piece of functionality, add it in. We know We know! It’s just another PR we have to review and merge. You’re right, it is! However, the more tests we have, the earlier our CI tool can catch issues, saving us a review as well as back and forth time.
@andy-trimble, @ayushkalani, @chinurox, @dhsrocha, @huytranrjc, @lanre01, @mbernier, @mithunsasidharan, @Nikhil2508, @pushkyn, @rkaranam, @thepriefy, @tsuyoshizawa
Generally, instead of request.requestBody it should be request.body
This will be a breaking change.
I am getting classnotFound: SendgridResponseHandler, sometimes I am getting java.lang.ClassNotFoundException: org.apache.http.impl.client.AbstractResponseHandler but the mail is being sent. While fetching the response data , it is giving this error. I suppose some mismatch of jar versions.
I want to supply an underlying HTTP Client to be able to set a timeout and as well set the test
property.
Currently, these are the constructors exists-
public Client()
public Client(CloseableHttpClient httpClient)
public Client(Boolean test)
I will add another constructor that gets these two parameters.
Seems that the intention of passing the http was for mocking but another use case is to be able to set up the http client (for example set up timeout).
It is really nice to be able to develop locally inside a docker container! Please dockerize this repo!
Move the example and the link to the examples files to the USAGE.md File
Move the Environment variable information to USAGE.md
Remove the Usage Header from README
Change the link in the Table of Contents of README to go to USAGE.md File
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.