We have hosted our storage on AmazonS3 so you are getting the exception from AmazonS3.
I get this error even though my Azure storage account is set to be the default.
Here’s the code (C#):
static void AsposeTest()
{
var CLIENT_ID = "<redacted>";
var CLIENT_SECRET = "<redacted>";
var BASEPATH = "https://api.aspose.cloud";
var AUTHPATH = "https://api.aspose.cloud";
IStorageApi storageApi = new StorageApi(CLIENT_ID, CLIENT_SECRET, BASEPATH, AUTHPATH);
var x = storageApi.StorageExists("davetest");
var y = storageApi.StorageExists("cubiksdavetest");
Console.WriteLine($"davetest exists: {x}. cubiksdavetest exists: {y}");
var sourceUrl = "https://reporting-delivery-service.azurewebsites.net/report";
var width = 800;
var height = 1200;
var leftMargin = 15;
var rightMargin = 15;
var topMargin = 15;
var bottomMargin = 15;
var fileName = "HTMLPage1.html";
var outPath = @"c:\temp";
IConversionApi convApi = new HtmlApi(CLIENT_ID, CLIENT_SECRET, BASEPATH, AUTHPATH);
try
{
var response = convApi.GetConvertDocumentToPdfByUrl(
sourceUrl, width, height,
leftMargin, rightMargin, topMargin, bottomMargin);
if (response?.ContentStream != null)
{
var stream = response.ContentStream;
var outFile = Path.Combine(outPath, response.FileName);
if (!Directory.Exists(outPath)) Directory.CreateDirectory(outPath);
using var fstr = new FileStream(outFile, FileMode.Create, FileAccess.Write);
stream.CopyTo(fstr);
fstr.Flush();
Console.WriteLine($"GetConvertDocumentToPdfByUrl Succeeded ({response.Status}): result file saved to {outFile}");
}
else
{
Console.WriteLine("Empty response");
}
}
catch (Exception e)
{
Console.WriteLine($"Exception from GetConvertDocumentToPdfByUrl: {e}");
throw;
}
try
{
var response = convApi.GetConvertDocumentToPdf(
fileName, width, height,
leftMargin, rightMargin, topMargin, bottomMargin,
null, null);
if (response?.ContentStream != null)
{
var stream = response.ContentStream;
var outFile = Path.Combine(outPath, response.FileName);
if (!Directory.Exists(outPath)) Directory.CreateDirectory(outPath);
using var fstr = new FileStream(outFile, FileMode.Create, FileAccess.Write);
stream.CopyTo(fstr);
fstr.Flush();
Console.WriteLine($"GetConvertDocumentToPdf Succeeded: result file saved to {outFile}");
}
else
{
Console.WriteLine("Empty response");
}
}
catch (Exception e)
{
Console.WriteLine($"Exception from GetConvertDocumentToPdf: {e}");
}
try
{
var response = convApi.PostConvertDocumentToPdf(fileName, $"report.pdf", width, height, leftMargin, rightMargin, topMargin, bottomMargin, null);
if (response != null)
{
Console.WriteLine($"PostConvertDocumentToPdf Succeeded ({response.Status}): Result file uploaded as report.pdf");
}
}
catch (Exception e)
{
Console.WriteLine($"Exception from PostConvertDocumentToPdf: {e}");
}
}
The output of this code is:
davetest exists: False. cubiksdavetest exists: False
GetConvertDocumentToPdfByUrl Succeeded (OK): result file saved to c:\temp\report_converted.pdf
Exception from GetConvertDocumentToPdf: Aspose.Html.Cloud.Sdk.Client.ApiException: Error calling GetConvertDocumentToPdf: StatusCode=500 (InternalServerError); Internal Server Error
at Aspose.Html.Cloud.Sdk.Api.Internal.ApiImplBase.CallGetApi(String path, Dictionary`2 queryParams, String methodName) in C:\Source\Samples\aspose-html-cloud-dotnet\Aspose.HTML-Cloud\Api\Internal\ApiImplBase.cs:line 69
at Aspose.Html.Cloud.Sdk.Api.Internal.ConversionApiImpl.GetConvertDocumentToPdf(String name, Nullable`1 width, Nullable`1 height, Nullable`1 leftMargin, Nullable`1 rightMargin, Nullable`1 topMargin, Nullable`1 bottomMargin, String folder, String storage) in C:\Source\Samples\aspose-html-cloud-dotnet\Aspose.HTML-Cloud\Api\Internal\ConversionApiImpl.cs:line 174
at Aspose.Html.Cloud.Sdk.Api.HtmlApi.GetConvertDocumentToPdf(String name, Nullable`1 width, Nullable`1 height, Nullable`1 leftMargin, Nullable`1 rightMargin, Nullable`1 topMargin, Nullable`1 bottomMargin, String folder, String storage) in C:\Source\Samples\aspose-html-cloud-dotnet\Aspose.HTML-Cloud\Api\HtmlApi.cs:line 413
at HtmlToPdfTest.Program.AsposeTest() in C:\Source\NexusReporting\HtmlToPdfTest\Program.cs:line 179
PostConvertDocumentToPdf Succeeded (NoContent): Result file uploaded as report.pdf
The PDF output from GetConvertDocumentToPdfByUrl is a 0 length file.