psycodad 3 Posted February 13, 2019 Hello, I have to migrate to new microsoft translation api. I try to translate the text with the new RestDebugger. It seems to be easy reading the https://docs.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-translate?tabs=curl I set all the RestDebugger properties i need but all i get is a "400:BadRequest", "One of the request inputs is not valid". In the pics attached you can see how i configure the RestDebugger. I downloaded a c# demo project from https://github.com/MicrosoftTranslator/Text-Translation-API-V3-C-Sharp-Tutorial After setting the COGNITIVE_SERVICES_KEY to my key, change the url to TEXT_TRANSLATION_API_ENDPOINT = "https://api-eur.cognitive.microsofttranslator.com/{0}?api-version=3.0", and comment out the two header entries //request.Headers.Add("Ocp-Apim-Subscription-Region", "westus"); //request.Headers.Add("X-ClientTraceId", Guid.NewGuid().ToString()); all works well. I assume the problem is in the content body. Can someone point me to the right direction? Share this post Link to post
Dave Nottage 557 Posted February 13, 2019 The URL you are sending to does not appear to have any of the required values. It should (according to the link you gave) look at least something like this: https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=de Share this post Link to post
psycodad 3 Posted February 14, 2019 (edited) I use https://api-eur.cognitive.microsofttranslator.com/translate?api-version=3.0@&from=en&to=de That works well with the c# project with microsoft visual studio. The only difference between your and my URL is that i use the european located server "api-eur." instead of the us "api.". I think i do something wrong in the RestDebuggers "user defined content". Calling the "languages" ressources works well. There i do not need a request json content body parameter (see pics). Edited February 14, 2019 by psycodad Share this post Link to post
psycodad 3 Posted February 15, 2019 Found the solution: - Empty TRestRequest.Ressource property - Remove all parameters except the Header with the subscription key - Use following BaseURL instead: https://api-eur.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=de Now all works like expected. But i even do not know why i should not use the TRestRequest.Params and the Ressource property instead of the URL parameters... 1 Share this post Link to post
psycodad 3 Posted February 18, 2019 Here a small working demo project how to get translations.. translation api.zip 1 1 Share this post Link to post
Mokofay 0 Posted February 17, 2021 I just wanted to express my thanks for this sample. I tried for days to get this to work with various languages including C# but with no luck at all. Regards -Mohamed Share this post Link to post