Skip to content

Delayed SMS with Message.setScheduledDatetime() does not work #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
madness-inc opened this issue Feb 24, 2017 · 3 comments
Closed

Delayed SMS with Message.setScheduledDatetime() does not work #20

madness-inc opened this issue Feb 24, 2017 · 3 comments
Labels

Comments

@madness-inc
Copy link

madness-inc commented Feb 24, 2017

StackTrace:
com.messagebird.exceptions.GeneralException: Failed to retrieve data from MessageBird service with response code 422 at com.messagebird.MessageBirdServiceImpl.getJsonData(MessageBirdServiceImpl.java:140) at com.messagebird.MessageBirdServiceImpl.sendPayLoad(MessageBirdServiceImpl.java:107) at com.messagebird.MessageBirdClient.sendMessage(MessageBirdClient.java:110)

ErrorReport{code=10, description='The scheduledDatetime is not in a valid format (Y-m-d\TH:i:sP).', parameter='scheduledDatetime'}

The reason is that the scheduledDatetime is not properly transformed to JSON in MessageBirdServiceImpl.getConnection()

This could easily be solved by upgrading to Jackson 2 and using

@JsonFormat(shape = Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssXXX")
public Date getScheduledDatetime() {
	return scheduledDatetime;
}

in Message.java

Alternative:

DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
mapper.setDateFormat(df);
@samwierema
Copy link
Contributor

Hi @madness-inc,

Thanks for opening an issue. Our team will review the issue and get back to you with a solution as soon as we can. In the meantime, for our reference, could you tell us what version of Java you're using?

@samwierema samwierema added the bug label Mar 6, 2017
@madness-inc
Copy link
Author

Hi Sam,
glad to hear from you!
I'm using Java 8, but his is not a Java issue. It's a Jackson Mapping issue.
As there is no standard way of mapping a java.util.Date into JSON format, we need to tell the Jackson Mapper how to do this. Both of my suggested solutions are suitable for that, although I personally would prefer the Jackson 2 solution.

Regards
Matthias

@samwierema
Copy link
Contributor

@madness-inc this has now been merged and will be released as version 1.3.1. Thanks much for opening an issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants