sargue / mailgun

Java library to easily send emails using the Mailgun service
MIT License
153 stars 40 forks source link

How best to debug a bad request? #8

Closed RobWills closed 8 years ago

RobWills commented 8 years ago

Sergi, Firstly thank you for writing this first class wrapper. Well written and documented.

What would be the best way for me to debug a message I'm trying to send that has a response of 400? I am obviously providing some duff information somewhere. Is it possible to return what I am trying to post in some way? It is not complicated. In fact very much like your most simple example.

sargue commented 8 years ago

You say you are getting a 400 so I'm assuming you've noticed that the send() method returns a Response object. Have you tried reading the response message to check for any error code or explanation?

RobWills commented 8 years ago

I got the Response object returned by the Send() method. IsOK() returned false and the value of responseCode() was 400 meaning BAD_REQUEST. However, I am not sure how to get at any text returned. There didn't seem to be any suitable method in the JavaDoc for the Response class.

OK cancel that! I just looked at your source and saw the ResponseMessage() method. I will give that a go. Oops.

sargue commented 8 years ago

You're right! It's a change not yet commited, sorry about that. Time to publish a new version. :-)

RobWills commented 8 years ago

Ah thanks. I'd just come to that conclusion.

sargue commented 8 years ago

I have published a new version, 1.3.0, which contains this new method.

It is already available if you use bintray's jcenter and it's currently syncing with Maven Central which usually takes some hours.

RobWills commented 8 years ago

Excellent, thanks!!