Repository navigation
Description
Issue Summary
It's not possible to disable tracking settings for a single email, e.g. click_tracking, because the "enabled" flag does not get serialised to JSON if it is false (default value) and the SendGrid server rejects the request as a result of that. In this example I used click_tracking, but this should also be changed for other tracking settings.
Steps to Reproduce
- This is how I disable click tracking for a single email
TrackingSettings trackingSettings = new TrackingSettings();
// disable click tracking
ClickTrackingSetting clickTrackingSetting = new ClickTrackingSetting();
clickTrackingSetting.setEnable(false);
clickTrackingSetting.setEnableText(false);
trackingSettings.setClickTrackingSetting(clickTrackingSetting);
this.mail.setTrackingSettings(trackingSettings); // com.sendgrid.Mail- This is how I send the email
Request request = new Request();
this.mail.addPersonalization(personalization);
request.method = Method.POST;
request.endpoint = "mail/send";
request.body = mail.build(); // this is the important part
Response response = this.api(request);-
mail.build()does not include the click_tracking settings. Those "enable" booleans will not get serialized if they are false because of@JsonInclude(Include.NON_DEFAULT)inClickTrackingSetting(false is the default value of boolean).mail.build()creates a JSON that looks like this:"tracking_settings":{"click_tracking":{}}when I want to disable click tracking.
I expect it to look like this:"tracking_settings":{"click_tracking":{"enable": false, "enable_text": false}} -
The SendGrid server rejects the JSON created by
mail.build()containing"tracking_settings":{"click_tracking":{}}but accepts my manually created JSON containing"tracking_settings":{"click_tracking":{"enable": false, "enable_text": false}}
Possible solution:
Instead of boolean(primitive) with default value false, use Boolean(object) with default value null to enable/disable settings.
Example ClickTrackingSetting.java:
@JsonProperty("enable") private Boolean enable;
instead of
@JsonProperty("enable") private boolean enable;
Technical details:
- sendgrid-java Version: v3.1.0
Activity
thinkingserious commentedon Jan 26, 2017
Thanks @LTholen,
I've added this to our backlog for a fix.
simon-heinen commentedon Apr 24, 2017
@thinkingserious any update on this?
thinkingserious commentedon Apr 29, 2017
Hi @simon-heinen,
I have added your vote to this issue in our backlog. For this issue to rise in our backlog, we need more participants on this thread. The fastest way for it to rise is with a PR.
Thank you!
Elmer
hc1jcarter commentedon Jun 9, 2017
This is a huge blocker for us as well.
thinkingserious commentedon Jun 10, 2017
Thanks @hc1jcarter,
Your vote has been added.
While this issue is continuing to climb in our backlog, it's fairly down on the list right now. The best chance for this to be fixed shortly will be a PR. If anyone is interested, I'm happy to help with that.
With Best Regards,
Elmer
Alway serialize click-tracking parameters
roshanail commentedon Nov 27, 2017
I noticed that click tracking has been fixed. However open tracking still has the Include.NON_DEFAULT annotation in it.
So has it only been fixed for click tracking and not the other tracking settings?
thinkingserious commentedon Nov 28, 2017
Hi @roshanail,
Can you please point me to where you are seeing that? This is what I see.
With Best Regards,
Elmer
roshanail commentedon Dec 12, 2017
Looks like it came in on this merge you did 14 days ago
22ba9e9#diff-39711246df8201ee796925f1177ea824
It wasn't there when I looked at it.
Thanks for the update
thinkingserious commentedon Dec 14, 2017
Thanks for following up @roshanail!