Translate Method

Translates a text string from one language to another.

Request URI

URI parameters
Parameter Description


Required. A string containing "Bearer" + " " + access token.


Required. A string representing the text to translate. The size of the text must not exceed 10000 characters.


Optional. A string representing the language code of the translation text. If left empty the response will include the result of language auto-detection.


Required. A string representing the language code to translate the text into.


Optional. The format of the text being translated. The supported formats are "text/plain" and "text/html". Any HTML needs to be well-formed.


Optional. A string containing the category (domain) of the translation. Defaults to "general".

Return value
A string representing the translated text. If you previously use AddTranslation or AddTranslationArray to enter a translation with a rating of 5 or higher for the same source sentence, Translate returns only the top choice that is available to your system. The "same source sentence" means the exact same (100% matching), except for capitalization, white space, tag values, and punctuation at the end of a sentence. If no rating is stored with a rating of 5 or above then the returned result will be the automatic translation by Microsoft Translator.

Ff512406.alert_note(en-us,MSDN.10).gif Note

Bing App ID is deprecated and is no longer supported.   Please obtain an access token to use the Microsoft Translator API. For details, go here.


Obtain an Access Token on the server-side

public static AdmAccessToken GetAccessToken()
    AdmAccessToken admToken;
    string headerValue;
    //Get Client Id and Client Secret from
    AdmAuthentication admAuth = new AdmAuthentication("clientid", "clientsecret");

    admToken = admAuth.GetAccessToken();
    // Create a header with the access_token property of the returned token
    headerValue = "Bearer" + " " + HttpUtility.UrlEncode(admToken.access_token);

    return admToken;
Invoke the AJAX method on the client-side

<html xmlns="">
<head runat="server">
    <script type="text/javascript">
        var languageFrom = "en";
        var languageTo = "de";
        var text = "Use pixels to express measurements for padding and margins.";
        function translate() {
            PageMethods.GetAccessToken(OnSucceeded, OnFailed);

        function OnSucceeded(result, usercontext, methodName) {

            window.mycallback = function (response) {
                document.getElementById('<%= lblResult.ClientID %>').innerHTML = "Translation for <br />source text: '" + text + "'<br /> from en to de <br /> " + response;

            var s = document.createElement("script");
            s.src = " " + encodeURIComponent(result.access_token) + "&from=" + languageFrom + "&to=" + languageTo + "&text=" + text;
        function OnFailed(error, userContext, methodName) {
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager" runat="server" EnablePageMethods="true" />
        <asp:Button ID="buttonTranslate" runat="server" Text="Translate" OnClientClick="translate();return false;" />
        <br />
        <asp:Label ID="lblResult" runat="server"></asp:Label>