I’m using asposecellscloud@21.8.0. The code is very easy:
import { CellsApi, CellsWorkbook_PutConvertWorkbookRequest } from 'asposecellscloud';
import { readFile, writeFile } from 'fs/promises'
const cellsApi = new CellsApi(clientId, clientSecret, 'v3.0');
const xlsRequest = new CellsWorkbook_PutConvertWorkbookRequest({
file: await readFile(xlsxToConvert),
format: 'pdf'
});
const xlsRes = await cellsApi.cellsWorkbookPutConvertWorkbook(xlsRequest);
when I run this example with valid credentials, I’m getting HTTP 500.
in the HTTPS trace I’m getting this error:
{
"RequestId":"53094f6e-65c1-4df5-885f-babfb0425cd6",
"Error":{
"Code":"internalError",
"Message":"Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')",
"Description":"Operation Failed. Internal error.",
"DateTime":"2021-09-29T16:50:42.310799Z"
}
}
tried the same API method via API tester and via Postman - works fine.
Thanks, @wangtao, it works (at least the error has gone).
However, the resulting PDF is empty.
Attaching the input file (XSLS in zip archive) and resulting PDF
The same file converted OK if I run the request via Postman.
So looks like it has something to do with the nodejs SDK itself or the way how the response is stored to the file.
I tried writeFile from fs/promises and writeFileSync from fs - the same result (empty file).
I tried changing my code to what you have suggested - no difference.
However, I grabbed the response coming from the server (using Wireshark) and the response is correct.
I compared it with what comes in the response.body and it looks like binary format is converted to string, which corrupts the data.
See the snapshot.
the left side is what comes in response.body (empty PDF)
the right side is grabbed response (valid PDF)
The line at the bottom shows the difference in bytes: some characters are replaced with 0xFD
It looks like the asposecellscloud has a bug that needs to be fixed.
FYI: checked how docx conversion (ConvertDocumentRequest of asposewordscloud) handles the response - looks like it returns Buffer (which is good).
@ScottHeide,
We thank you for being able to use the NodeJS SDK.
We will continue to solve this problem and optimize the SDK.
We hope you can continue to try the new version of the SDK in the future.