Convert Microsoft Excel Workbook to PDF and save to Windows Azure blob storage using Aspose.Cells REST API throws Error 404

Hi,

I am totally new to Aspose and ran into an issue with converting an excel file to PDF using Aspose.Cells.Cloud.SDK and storing it in Azure blob storage. Below are the details –

Error calling CellsSaveAsPostDocumentSaveAs: {“RequestId”:"|0fd365142400bb44a1db9ba676fd7e79.4d23fbf697a61a46.",“Error”:{“Code”:“errorLoadFile”,“Message”:“Windows Azure Storage exception: The remote server returned an error: (404) Not Found.”,“Description”:“Operation Failed. Loading file to workbook fails.”,“DateTime”:“2021-05-09T21:09:02.1673646Z”,“InnerError”:null}}

Any help is greatly appreciated. Thank you in advance.

Regards
Shravi

@s2205,

It looks like you are passing incorrect file name, folder name or storage name in the API call. Please pass correct parameter values, it will resolve the issue.

Please refer following codes:

CellsApi cellsApi = new CellsApi(“clientId”, “clientSecret”,“v3.0”);
Stream stream = Tools.GetFileStream(“Book1.xlsx”);
stream.Seek(0, SeekOrigin.Begin);
cellsApi.UploadFile(“CustomTest_7193.xlsx”, stream, “DropBox”);
cellsApi.CellsSaveAsPostDocumentSaveAs(“CustomTest_7193.xlsx”, null, “CustomTest_7193.xlsx.pdf”, null, null, null, “DropBox”);

Thank you for your response. I checked the values by logging the azure application insights - the path(URL’s) of these excel files stored on Azure is correct ( I pasted the URL’s in the browser and the files got downloaded properly)

Below is the code for your reference which takes in excel files and converts to PDF and stores them in a sub folder called ‘converted’ under ‘books’ folder in Azure blob storage.

if (ext == “xlsx” || ext == “xls” || ext == “xlsm”)
{
try
{
var apiInstance = new CellsApi(_settings.AsposeClientId, _settings.AsposeClientKey);
var name = fileInfo[2]; // string | The document name.
_telemetryTracker.TrackTrace(string.Format(“name: {0}”, name), true);
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.SaveFormat = “pdf”;
var newfilename = “converted/” + fileNameNoExt + “.pdf”;
_telemetryTracker.TrackTrace(string.Format(“New File Name: {0}”, newfilename), true);
var isAutoFitRows = true;
var isAutoFitColumns = true;
var folder = “books”;
var storage = _settings.AsposeStorageName;

                        // Convert document and save result to storage.
                        Aspose.Cells.Cloud.SDK.Model.SaveResponse result =  apiInstance.CellsSaveAsPostDocumentSaveAs(name, saveOptions, newfilename, isAutoFitRows, isAutoFitColumns, folder, storage);
                        
                    }
                    catch (Exception e)
                    {
                        var errmsg = "Exception when calling CellsSaveAsApi.CellsSaveAsPostDocumentSaveAs: " + e.Message + Environment.NewLine + e.StackTrace;
                        Console.Write(errmsg);
                        _telemetryTracker.TrackException(new Exception(errmsg));
                    }

The line where error is thrown : Aspose.Cells.Cloud.SDK.Model.SaveResponse result = apiInstance.CellsSaveAsPostDocumentSaveAs(name, saveOptions, newfilename, isAutoFitRows, isAutoFitColumns, folder, storage);

Please help. Is there a way to verify if the storage name is correct?

Greatly appreciate all your time and help.

@s2205,

Please login to Aspose Cloud dashboard, search windows azure storage from 3rd party storage and pass the correct storage name in the API call.
If you have not configured your windows azure storage with Aspose Cloud then please refer to Configure Azure Storage article to configure your windows azure storage and use the storage name in the API call.

Thank you. Will check it out. Could there be any other reasons for error 404? How does Aspose in general process excel files and convert it to PDF?

@s2205
Please refer to the online document about Convert Excel and following codes:

CellsApi cellsApi = new CellsApi(“your clientId”, “your clientSecret”);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.OnePagePerSheet = true;
Stream stream = Tools.GetFileStream(“Book1.xlsx”);
stream.Seek(0, SeekOrigin.Begin);
cellsApi.UploadFile(“CustomTest_7193.xlsx”, stream,“your storage name”);
cellsApi.CellsSaveAsPostDocumentSaveAs(“CustomTest_7193.xlsx”, pdfSaveOptions, “CustomTest_7193.xlsx.pdf”, null, null , “your storage name”);

Thank you for your help. Finally, was able to resolve this issue and it just happened to that Aspose is configured to point to another blob storage container instead of ‘books’ container as shown in the code above. Changing the container name/ folder in the code solved the problem.

Appreciate all your time.