How to translate HTML page into other languages in .NET using Aspose.HTML REST API

Hi!
I got an exception (“Error calling GetTranslateDocument: StatusCode=500 (InternalServerError); One or more errors occurred.”), when I ran following fragment:

string BasePath = "https://api.aspose.cloud/v1.1";

string name = "test.html";

string outPath = @"c:\tmp\";
string outFile = Path.Combine(outPath, $"{Path.GetFileNameWithoutExtension(name)}_EnglishRu.html.zip");

const string srcLang = "en"; // String | Source language.
const string resLang = "ru"; // String | Result language.
string folder = null;     // root folder
string storage = null;    // default storage

try
{
    ITranslationApi transApi = new TranslationApi(AppKey, AppSid, BasePath);
    var response = transApi.GetTranslateDocument(name, srcLang, resLang, storage, folder);

    if (response is FileStream)
    {
        if (!Directory.Exists(outPath)) Directory.CreateDirectory(outPath);
        using (Stream fstr = new FileStream(outFile, FileMode.Create, FileAccess.Write))
        {
            response.CopyTo(fstr);
            fstr.Flush();
            Console.Out.WriteLine($"Result file copied to: {outFile}");
        }
    }
}
catch (Exception ex)
{
    Console.Out.WriteLine($"Error: {ex.Message}");
}

@Andruhovski

Thank you for contacting us.

It looks like an outdated code. Please check Translate HTML page article for updated cURL and SDK Examples.

Cloud SDKs for all major platforms are available at Aspose.HTML Cloud · GitHub.

We hope this helps!