Hello all,
I am still a newbie in communication with servers and have the following problem:
I want to automatically translate text from a database using a translator. For this I want to use the LibreTranslator (Link). LibreTranslate directly provides an example of a query in JavaScript:
const res = await fetch("https://de.libretranslate.com/translate", {
headers: { "Content-Type": "application/json" }
console.log(await res.json());
Now I would like to implement this request in MATLAB. For this I have resorted to webwrite and tried to write a query as in this Example. The content of my function is as follows:
api = 'https://de.libretranslate.com/translate';
if ~exist('options','var')
options.RequestMethod="post";
options.MediaType = "application/json";
s = webwrite(api,body,options);
When I run this now I get the following error:
---------------------------------------------------------------------------------------------------------------------------------------------------
Error using matlab.internal.webservices.HTTPConnector/copyContentToByteArray
The server returned the status 500 with message "Internal Server Error" in response to the request to URL
https://de.libretranslate.com/translate.
---------------------------------------------------------------------------------------------------------------------------------------------------
I have also already tried to create a json file that has exactly the structure from the example query and pass this. The result remained the same.
"Content-Type": "application/json"
I would be very happy if someone could help me here.
Many thanks and many greetings
Tom