mailjet / mailjet-apiv3-java

[API v3] Mailjet Java API Wrapper
https://dev.mailjet.com
MIT License
66 stars 36 forks source link

NullPointerException on a v1 account #54

Closed BenoitDD-URIOS closed 8 years ago

BenoitDD-URIOS commented 8 years ago

We are implementing a plug-in based on the API v3 Java client. When we try to send a transactional email, we have a NullPointerException.

Here his the output with the VERBOSE_DEBUG :

=== HTTP Request ===
POST https://api.mailjet.com/v3/send
Accept-Charset:UTF-8
Accept:application/json
user-agent:mailjet-apiv3-java/v3.0.0
Content-Type:application/json
=== HTTP Response ===
Receive url: https://api.mailjet.com/v3/send
Status: 400
null:HTTP/1.1 400 Wrong API version
Server:nginx
Connection:keep-alive
Vary:Accept-Encoding
Content-Length:0
Date:Fri, 19 Feb 2016 15:37:33 GMT
Content-Type:text/html
Content:
null
java.lang.NullPointerException
    at java.io.StringReader.<init>(StringReader.java:50)
    at org.json.JSONTokener.<init>(JSONTokener.java:84)
    at org.json.JSONObject.<init>(JSONObject.java:321)
    at com.mailjet.client.MailjetClient.post(MailjetClient.java:155)
    at amo.plugin.vendors.mailjet.editor.blender.model.WsDataConsumer.setConsumed(WsDataConsumer.java:140)
    at amo.editor.blender.model.file.EmptyChainedDataConsumers.setConsumed(EmptyChainedDataConsumers.java:71)
    at amo.editor.blender.model.file.DataConsumersAbstract.setConsumed(DataConsumersAbstract.java:15)
    at amo.editor.blender.XslFoTool._xslMerge(XslFoTool.java:182)
    at amo.editor.blender.XslFoTool.xslMerge(XslFoTool.java:122)
    at amo.editor.blender.Main.transform(Main.java:129)
    at amo.editor.blender.Main.main(Main.java:101)

Our account seems to use the deprecated v1 API, so we need to migrate it (see mailjet/mailjet-apiv3-nodejs#3).

The MJ Java client should throw a custom error in this case.

WeshGuillaume commented 8 years ago

Hey @Benoit-amo !

Thanks for reporting this issue! I am going to work on a custom error message in that case. I'll keep you up to date by tomorrow :airplane:

Regards, Guillaume

WeshGuillaume commented 8 years ago

The errors are not thrown anymore, but it will be hard for us to integrate a custom message for V1 users

BenoitDD-URIOS commented 8 years ago

Ok, thanks for the fix.