Accessing Microsoft Translator HTTP webservice
-
יום שלישי 17 אפריל 2012 20:05
I want to access Microsoft Translator web service through HTTP interface. After obtaining an access token I can't obtain any translation. I put
http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=Bearer <token>&text=Hello&from=en&to=fr
into the my browser address field (<token> is the token i received from Azure). It returns me the error message:
The Web Token must have a signature at the end. The incoming token did not have a signature at the end of the token.
I have tried replacing <token> with URI encoded(<token>), replacing the space after "Bearer" with a "+" without any result.
Please help me! Thanks.
כל התגובות
-
יום שני 23 אפריל 2012 16:25
Hi Clovis,
Have you had a chance to look the following sites? The sample codes provided there should work for you.
http://msdn.microsoft.com/en-us/library/ff512387.aspx
http://msdn.microsoft.com/en-us/library/ff512421.aspx
Let me know how it goes.
Thanks. Takako (Microsoft Translator Team)
-
יום שלישי 24 אפריל 2012 02:45I also have the same problem, but the documents listed above don't give the answer. The error message is that the token is lacking a signature at the end but the references given don't refer to a signature. At the end of the token, shouldn't the GET url simply continue with "&" on to the next parameter? What is a "signature"?
-
יום שלישי 24 אפריל 2012 15:46
Hi Skylang and Clovis,
The sites below discuss a "signature" issue. Take a look. Hope that you can find a solution there. Let us know how it goes. Takako
-
יום רביעי 25 אפריל 2012 15:46
Take a look at the code I posted in these threads:
Some Code Samples:
C# Asynchronous and Synchronous examples in here:
http://social.msdn.microsoft.com/Forums/en-US/microsofttranslator/thread/02054a7c-090c-46a0-a8d1-2d57e236eb4d
And VB on this thread:
http://social.msdn.microsoft.com/Forums/en-US/microsofttranslator/thread/3f9a270e-3360-4aa1-9eb8-669145298d45I have verified that these are working for the service...see if you are doing anything different?
//Laurence Moroney: www.netnavi.tv // Author of 'Introducing Silverlight' series and much more // @lmoroney
-
יום רביעי 25 אפריל 2012 15:49So can it only be accessed by POST, not GET?
-
יום חמישי 26 אפריל 2012 14:17
For GET, try this:
string headerValue = "Bearer " + token.access_token;
string uri = "http://api.microsofttranslator.com/v2/Http.svc/Translate?appid= " + System.Net.HttpUtility.UrlEncode(headerValue) + "&text=" + System.Net.HttpUtility.UrlEncode(strTextToTranslate) + "&from=en&to=es";
Note that I System.Net.HttpUtility.UrlEncode the header Value containing the Bearer.
I've tried this on the Ajax.svc and it worked...haven't had time to rebuild my app to see if that works with the Http service, because I usually POST with that...
//Laurence Moroney: www.netnavi.tv // Author of 'Introducing Silverlight' series and much more // @lmoroney