KeyError: 'RequestId'

Is aspose words cloud python SDK still being maintained? I executed this code after installing the latest version of the package. This code is exactly what’s provided in sample code github gists.

import os
import asposewordscloud
from asposewordscloud import WordsApi
from asposewordscloud.models.requests import (
    UploadFileRequest,
    SplitDocumentRequest,
    DownloadFileRequest,
    ConvertDocumentRequest,
    SplitDocumentRequest
)
from asposewordscloud.rest import ApiException
from shutil import copyfile

ASPOSE_CLIENT_ID="..."
ASPOSE_CLIENT_SECRET="..."

words_api = WordsApi(client_id = ASPOSE_CLIENT_ID, client_secret = ASPOSE_CLIENT_SECRET) 
split_request = SplitDocumentRequest(name='Sample.docx', format='text', dest_file_name='SplitDocument.text', _from=1, to=2)
words_api.split_document(split_request)

Output:

KeyError                                  Traceback (most recent call last)
<ipython-input-11-993358b46241> in <cell line: 19>()
     17 words_api = WordsApi(client_id = ASPOSE_CLIENT_ID, client_secret = ASPOSE_CLIENT_SECRET)
     18 split_request = SplitDocumentRequest(name='Sample.docx', format='text', dest_file_name='SplitDocument.text', _from=1, to=2)
---> 19 words_api.split_document(split_request)

8 frames
/usr/local/lib/python3.10/dist-packages/asposewordscloud/rest.py in init_error_response(self, json_object)
    271 
    272     def init_error_response(self, json_object):
--> 273         self.body = WordsApiErrorResponse(json_object["RequestId"], self.init_error(json_object["Error"]))
    274 
    275     def init_error(self, error_object):

KeyError: 'RequestId'

@arjunmetaforms

The KeyError: 'RequestId' you are encountering typically indicates that the response from the Aspose API does not contain the expected RequestId field. This can happen for a few reasons, such as an issue with the API request or a problem on the server side.

Here are some steps you can take to troubleshoot this issue:

  1. Check API Credentials: Ensure that your ASPOSE_CLIENT_ID and ASPOSE_CLIENT_SECRET are correct and have the necessary permissions to perform the operation.

  2. Verify Document Existence: Make sure that the document Sample.docx you are trying to split actually exists in your Aspose storage. If the document is not found, the API may return an error that does not include the RequestId.

  3. Inspect API Response: You can modify your code to print the entire response from the API before it tries to access the RequestId. This will help you understand what the API is returning and why the RequestId might be missing.

  4. Update SDK: Ensure that you are using the latest version of the Aspose Words Cloud SDK for Python. Sometimes, issues are resolved in newer releases.

  5. Review Documentation: Check the official documentation for the SplitDocument method to ensure that you are using it correctly. The API allows you to split documents into various formats, and there may be specific requirements or limitations that you need to consider.

  6. Check for Known Issues: Visit the Aspose forums or GitHub repository to see if there are any known issues related to the KeyError you are experiencing. Other users may have encountered similar problems and found solutions.

If the problem persists after these checks, consider reaching out to Aspose support with details of your request and the error message for further assistance.

For more information on splitting documents using the Aspose API, you can refer to the official documentation here.

Sources:
[1]: Split a document into parts|Aspose Words Cloud Docs