简体   繁体   中英

How to get alternative translations using Microsoft Translator API GetTranslations

I would like to read alternative text translations for a given word using the getTranslations API. The web response status code looks OK but the response stream returns as null. Does anyone have a working example or point what's wrong with my code? Appreciate your help.

string uri = string.Format("https://api.microsofttranslator.com/V2/Http.svc/GetTranslation?         
text=Origin&from=es&to=de&maxTranslations=10");
WebRequest translationWebRequest = WebRequest.Create(uri);
                translationWebRequest.Headers.Add("Authorization", 
                 tokenProvider.GetAccessToken());
WebResponse response = null;
response = translationWebRequest.GetResponse();
Stream stream = response.GetResponseStream();

Use the new Microsoft Translator Text API v3 which includes a multi-lingual dictionary API. The v2 to v3 migration documentation is at www.aka.ms/Translatorv3Migration .

Thank you.

v3 is REST and JSON only. Dictionary documentation is in the v3 documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM