none
Always receiving "The received token is of incorrect token type" RRS feed

  • Question

  • Hi,

    I'm trying to access the Microsoft Translator SOAP API through SoapUI.

    Whereever I enter the access token, be it in the Authorization header or via <v2:appId>, I always get a message "The received token is of incorrect token type.".

    Same thing happens when I use the REST interface.

    I tried both, application client_id and secret and my personal id and secret - no success...

    Any ideas?

    Thanks a lot!

    - michael

    Wednesday, August 29, 2012 1:46 PM

Answers

  • Hi,

    As far as i know, Translator API is requires your Marketplace key, not application client_id and secret, i guess there's something wrong with you key or key type, Bing Translator API requires base64 format key as credential, would you like to share your code and more info about the error?

    Here is sample code about how to call Translator API via HttpRequest:

            string text = Server.UrlEncode(String.Format("'{0}'", "<Your Text>"));
            string toLanguage = Server.UrlEncode(String.Format("'{0}'", "<To Language code>"));
            string fromLanguage = Server.UrlEncode(String.Format("'{0}'", "<To Language code>"));
            HttpWebRequest request = HttpWebRequest.Create("https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/Translate?Text=" + text + "&To=" + toLanguage + "&From=" + fromLanguage + "&$top=100&$format=Raw") as HttpWebRequest;
            if (request.RequestUri.AbsoluteUri.Length > 2126)
            {
                tbTranslatedText.Text = string.Empty;
                lbWarnning.Text = "The source string is too long.";
                return;
            }
            NetworkCredential credential = new NetworkCredential("name", translatorPrimaryKey);
            request.Credentials = credential;
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            string result;
            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            {
                result = reader.ReadToEnd();
            }
    

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Thursday, August 30, 2012 4:53 AM
    Moderator