Forum Discussion
Microsoft Translator Support?
Hi,
I was planing to use the Microsoft Translator support for translating text in Power BI. Similar to the following example: https://www.youtube.com/watch?v=jZQ4BZmtseo . Base on the post https://community.powerbi.com/t5/Desktop/Sample-Power-BI-multilingual-support-report/td-p/57354 it seems to be that Microsoft Translator is not supported anymore. is that correct? Is there another way to use the API of Microsoft Translator?
Thanks a lot.
Cheers,
Dom
- Anonymous8 years ago
Hi v-huizhn-msft,
I was able to fix that issue.
First, to avoid the issue "A web API key can only be specified when a web API key name is provided" I had to set the "Data source settings" to "Anonymous". Because the M code is providing the API key logic there is no need to specify the key in the GUI of Power BI.
Second, in Power BI are two kinds of Data source settings: "Data source in current file" and "Global permissions". As far as I experienced it, the permission settings for the URL I'm using should be the same in either Global or Current File setting. Not sure if this is 100% correct but it worked for my case. Therefore, I set it credential type to "Anonymous" and privacy level to "None".
Afterwards I received the error message "Formula.Firewall: Query references other queries or steps, so it may not directly access data source. Please rebuild this data combination". To get rid of this error I set Power BI to ingore the Privacy in either Global or Current File setting under Option as mentioned in http://community.powerbi.com/t5/Desktop/Formula-Firewall-Query-references-other-queries-or-steps/td-p/150725.
Now, the translation feature is working without any errors.
Thanks for your help.
Cheers,
Dom
7 Replies
- v-huizhn-msftMicrosoft Employee
Hi Anonymous,
You can use Translator Text API in Power BI, more details, please follow the guide in the blog: Translate Text In Power BI Or Excel With Microsoft Translator Text API.
Best Regards,
Angelia- AnonymousNot applicable
Hi v-huizhn-msft,
Thanks for your support.
I read the blog post and tried to establish a connection by using the template DATACHANT is providing.
Unfortunately, I get the following error message when I fill in my Ocp-Apim-Subscription-Key: "A web API key can only be specified when a web API key name is provided". I am aware of serveral post discussing that issue but I still not sure what to do about it.
The function I am using to get the translater access looks like this:
let EmptyContent = Text.ToBinary("", TextEncoding.Ascii), Response = Web.Contents("https://api.cognitive.microsoft.com/sts/v1.0/issueToken", [ Headers = [ #"Content-Type"="application/json", Accept="application/jwt", #"Ocp-Apim-Subscription-Key"= TranslatorKey ], Content=EmptyContent ]), #"Imported Text" = Table.FromColumns({Lines.FromBinary(Response,null,null,20127)}), Res = #"Imported Text"{0}[Column1] in ResThe function to translate the text looks like this:
(textToTranslate, TranslateTolanguage) => let URL = "https://api.microsofttranslator.com/v2/http.svc/Translate?appid=Bearer " & GetTranslatorAccessToken & "&text=" & textToTranslate & "&to=" & TranslateTolanguage, Response = Web.Contents( URL, [ Headers = [Accept="application/xml"] ] ), XML = Xml.Tables(Response, null, 65001), TranslatedText = XML{0}[#"Element:Text"] in TranslatedTextApart from that, I already checked if my Ocp-Apim-Subscription-Key is valid by using http://docs.microsofttranslator.com/oauth-token.html#/ . So far the key is valid since I received the response code 200.
BTW the variable TranslatorKey is stored as a parameter in Power BI.
Do you have any suggestions?
Cheers,
Dom
- v-huizhn-msftMicrosoft Employee
Hi Anonymous,
The error means you need to specify an API key name in the headers area of Web.Contents using the advanced editor. I am not specific with API which is a part of developer, please see Chris Webb's post on this for a good example: https://blog.crossjoin.co.uk/2014/03/26/working-with-web-services-in-power-query/. Or please create a new thread in Power BI developer community, where you can get professional support. And welcome to share your workaround if you get answer.
Best Regards,
Angelia