Convert Microsoft Word Document to PDF using Aspose.Words REST API fails

Got this error when trying to convert doc file to pdf. Don’t know how but the next day it all works.

This happens a few times in the past. The workflow is

  1. Upload file to aspose
  2. Download it as PDF
  3. Delete it right after if no need

It failed on step 2 but oddly step 3 still works. Here’s the error.

Please help. Thanks

Error: Error while loading file 'How to Wash Your Hands_docx020d53e808ee288b3c57ca759ef61f5737104f6f.doc' from storage: AmazonS3 exception: Error 'The specified key does not exist.', Bucket 'afc-filestorage', FilePath '37482/2816f835-54ae-4178-b038-44a4ca194720/How to Wash Your Hands_docx020d53e808ee288b3c57ca759ef61f5737104f6f.doc' => Error while loading file 'How to Wash Your Hands_docx020d53e808ee288b3c57ca759ef61f5737104f6f.doc' from storage: AmazonS3 exception: Error 'The specified key does not exist.', Bucket 'afc-filestorage', FilePath '37482/2816f835-54ae-4178-b038-44a4ca194720/How to Wash Your Hands_docx020d53e808ee288b3c57ca759ef61f5737104f6f.doc' => AmazonS3 exception: Error 'The specified key does not exist.', Bucket 'afc-filestorage', FilePath '37482/2816f835-54ae-4178-b038-44a4ca194720/How to Wash Your Hands_docx020d53e808ee288b3c57ca759ef61f5737104f6f.doc'. Method: Export the document into the specified format.. Parameters: name 'How to Wash Your Hands_docx020d53e808ee288b3c57ca759ef61f5737104f6f.doc',format 'pdf',folder '',outPath ''

@bsohmers

Thank you for contacting us.

The specified key does not exist error means the specified file does not exist on Cloud Storage. Would you please ensure you are getting the following success response upon calling Upload file to Cloud Storage API.

{
  "Code": 200,
  "Status": "OK"
}

You may also verify the specified file has been successfully uploaded to Cloud Storage by visiting Dashboard.

@bsohmers

You may also use PUT /words/convert API to perform all three above steps in one API call.

Thanks for the reply.

We definitely check for 200 but the conversion might be the cause? Anyway, we will try the PUT /words/convert then save the file back.

Sure, please let us know if you face any issues.

@bsohmers

As an update, please note we have released API Version V4.0 of Aspose.Words Cloud in recent past. It has its own Storage API methods and uses JSON Web Token(JWT) for request authentication. Please check the sample cURL code to convert documents without using the storage. If you do not set the outPath parameter then ConvertDocument API returns the result in the response body as a stream and you can save it to the local drive.

PUT ​/words​/convert Converts a document on a local drive to the specified format. If you do not set

# First get Access Token
# Get Client Secret and Client ID from https://dashboard.aspose.cloud/
curl -X POST "https://api.aspose.cloud/connect/token" 
-d "grant_type=client_credentials&client_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxx" 
-H "Content-Type: application/x-www-form-urlencoded" 
-H "Accept: application/json"

# cURL example to convert MS Word Document to PDF
curl -v "https://api.aspose.cloud/v4.0/words/convert?format=pdf" 
-X PUT 
-F document=@TableDocument.doc 
-H "Content-Type: multipart/form-data" 
-H "Accept: multipart/form-data" 
-H "Authorization: Bearer <jwt token>" 
-o TableDocument.pdf