Excel to PDF conversion in apex Salesforce

Getting Status Code 500 Internal Server Error while sending request from Apex Salesforce for both saveAs and convert APIs.

here are the parameters for the body:
req.setBody(‘{“SaveOptions”:{“SaveFormat”: “pdf”}}’);
req.setBodyAsBlob(excelData);

where excelData is the VersionData field of content version of an excel file

@gkgaurav ,

Please post your test file here. We will check as soon as possible.

You can also refer to the following online articles on format conversion:

Convert Excel to kinds of format file.
How to convert file formats through Aspose.Cells Cloud.

Hi, it doesn’t allow me to upload xlsx file here. Getting “This is not a supported extension file”.

@gkgaurav ,
Please compress the Xlsx file into a zip archive and proceed with the upload.

Demo_Excel.zip (44.9 KB)

Please find the attached

@gkgaurav ,

Thank you for your share. We will check as soon as possible.

@gkgaurav ,
We tested the file you provided. It was successfully converted to PDF. Therefore, we believe the issue lies in the method of invocation. We recommend providing the conversion format parameters as query parameters, while only including file information in the body.

Please refer to the test code provided:

        const string format = "pdf";
        var url = string.Format("https://api.aspose.cloud/v3.0/cells/convert?format={0}", format);
        string bodyParam = null;
        Dictionary<string, string> headParams = null;
        Dictionary<string, object> formParams = new Dictionary<string, object>();
        var stream = ReadFromFile("Demo_Excel.xlsx");
        if (stream != null) formParams.Add("Demo_Excel.xlsx", ApiInvoker.ToFileInfo(stream, "File"));
        var response = ApiInvoker.InvokeApiAsync<Stream>(url, "PUT", bodyParam, headParams, formParams).Result;