1

I registered with Yandex and got a Translate API Key. However when I try to translate with the following code:

<CFSET Key = "trnsl.1.1.2014091...........................">
<CFSET lang="en-de">
<CFSET text="Hallo World">


<CFHTTP URL="https://translate.yandex.net/api/v1.5/tr.json/translate?Key=#Key#&lang=#lang#&text=#text#"  METHOD = "GET">
</CFHTTP>


<CFOUTPUT>#CFHTTP.FileContent#</CFOUTPUT>

I get a 401 error "API key is invalid". I also tried with Javascript/CFML but got a similar result. I have checked the key, and it is current.

Anyone got something similar working?

Leigh
  • 28,765
  • 10
  • 55
  • 103
JRH
  • 29
  • 4
  • Why was this down voted? Unlike some first posts, 1) the author clearly explained the problem 2) what steps they took to try and solve it, and 3) included a working repro case. Hardly worthy of a down vote .. – Leigh Sep 17 '14 at 21:20

1 Answers1

4

?Key=#Key#&lang=#lang#&text=#text#

This is going to sound a little crazy, but .. I think the reason is that the url parameter names are case sensitive. Since you are using ?Key= instead of ?key (all lower case) the receiving end thinks you did not supply an API key - at all. Hence the error. (Though "missing or invalid key" would be a little more accurate).

Try using ?key= (all lower case) instead and it should work.

Leigh
  • 28,765
  • 10
  • 55
  • 103