0

I was trying to make a text translator app using Microsoft-translator-API but I am not able to receive any response from this API, I always get this message:

[microsoft-translator-api] Error retrieving translation: Unable to resolve host "datamarket.accesscontrol.windows.net": No address associated with hostname

even I have given correct client Id and client secret Id.

I tried this link but I don't know where to put the JSON-Simple.jar file. I tried this link too but still with no success. I am pasting my code below:

public String translateText() throws Exception {
    Translate.setClientId("whateveritis");
    Translate.setClientSecret("whateveritis");

     translatedText = Translate.execute(
            userText.getText().toString(),
            languages[sEnterLan.getSelectedItemPosition()],
            languages[sTransLan.getSelectedItemPosition()]);

    Language detectedLanguage = Detect.execute(userText.getText()
            .toString());
    this.detectedLanguage = detectedLanguage.getName(Language.ENGLISH);

    return translatedText;
}

By calling above function I can receive the translated text into a string variable but every time I get an exception.

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

According to your code and reference links, I think you were using the third party Java wrapper boatmeme/microsoft-translator-java-api for MS Azure Translator API. However, it's an old Java wrapper which wrappered the old & unavailable APIs from the old site Azure datamarket. There is a notice at this site, and all origin APIs had been migrated to Azure subscription.

DataMarket and Data Services are being retired and will stop accepting new orders after 12/31/2016. Existing subscriptions will be retired and cancelled starting 3/31/2017. Please reach out to your service provider for options if you want to continue service.

So I suggested that you can try to refer to my answer for the other SO thread Microsoft Translator API Java, How to get client new ID with Azure to create a cognitive service for Translator Text API on Azure portal and use it via the new REST APIs.

Hope it helps.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43