You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.
i just try the lib today and i got a NullPointer :( can you help me please ?
try (DeepLClient client = new DeepLClient("")) {
TextTranslationResponse translation = client
.translate(new TextTranslationRequest("droite", TargetLanguage.AmericanEnglish));
System.err.println(translation.getTranslations().get(0).getText());
String result = translation.getTranslations().get(0).getText();
2022-08-09T10:05:24.874+02:00 DEBUG deepl.api.v2.logging.StdoutDeepLLogger - Sending a request:
POST https://api-free.deepl.com/v2/translate
body &text=droite&target_lang=EN-US
2022-08-09T10:05:25.427+02:00 DEBUG deepl.api.v2.logging.StdoutDeepLLogger - Received a response (1440 millis):
status 200
body
Exception in thread "main" java.lang.NullPointerException: gson.fromJson(body, Text…tionResponse::class.java) must not be null
at deepl.api.v2.json.GsonDeepLJsonSerializer.toTextTranslationResponse(GsonDeepLJsonSerializer.kt:33)
at deepl.api.v2.endpoint.TextTranslation$DefaultImpls.translate(TextTranslation.kt:94)
at deepl.api.v2.DeepLClient.translate(DeepLClient.kt:12)
at com.senefsoft.traductor.external.Translator.main(Translator.java:15)
The text was updated successfully, but these errors were encountered:
The body data may be empty in the scenario for some reason. Can you enable debug level logging to see the actual response status and body data from the API? If it is an error pattern, this SDK can improve the exception to be more developer-friendly.
Also, I highly recommend revoking the API token you embedded in the above code snippet.
Thanks for reporting this. Now that there is the official Java SDK, we recommend using https://github.com/DeepLcom/deepl-java instead. Let me close this issue and archive this repo.
2022-08-09T10:05:24.874+02:00 DEBUG deepl.api.v2.logging.StdoutDeepLLogger - Sending a request:
POST https://api-free.deepl.com/v2/translate
body &text=droite&target_lang=EN-US
2022-08-09T10:05:25.427+02:00 DEBUG deepl.api.v2.logging.StdoutDeepLLogger - Received a response (1440 millis):
status 200
body
Exception in thread "main" java.lang.NullPointerException: gson.fromJson(body, Text…tionResponse::class.java) must not be null
at deepl.api.v2.json.GsonDeepLJsonSerializer.toTextTranslationResponse(GsonDeepLJsonSerializer.kt:33)
at deepl.api.v2.endpoint.TextTranslation$DefaultImpls.translate(TextTranslation.kt:94)
at deepl.api.v2.DeepLClient.translate(DeepLClient.kt:12)
at com.senefsoft.traductor.external.Translator.main(Translator.java:15)
The text was updated successfully, but these errors were encountered: