Back to LanguageTool Homepage - Privacy - Imprint

Languagetool-server.jar won't return JSON-Format


i installed the standalone version on my ubuntu server.
I can send requests using curl and the response looks fine, too.

But I can’t get the results back in JSON. They are always getting returned in XML.

If I change the URL from my server to the JSON-format is returned.

I build the CURL-connection using php:

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded'
curl_setopt($ch, CURLOPT_URL, "IPOFSERVER:8081/?text=Hallo&language=de-DE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
echo ($output);

If I run the CURL-command from terminal it returns XML, too.

I started the program using:

java -cp languagetool-server.jar org.languagetool.server.HTTPServer --public --port 8081

What do I do wrong?

Thank you very much for your help!

Kind Regards

Please try "IPOFSERVER:8081/v2/check?text=Hallo&language=de-DE". Without the /v2/ you’ll end up in the old XML-based API.

1 Like

Perfect! Thank you very much. That solved it :slight_smile: