I have an error in this code, really no idea why
error: KeyError: ‘RequestId’
code:
import os
import asposewordscloud
from asposewordscloud import models
import asposewordscloud.models.requests
from shutil import copyfile
client_id = ‘xxx’
client_secret = ‘xxx’
words_api = asposewordscloud.WordsApi(client_id,client_secret)
words_api.api_client.configuration.host=‘https://api.aspose.cloud’
convert_request = models.requests.ConvertDocumentRequest(document=open(‘input.doc’, ‘rb’), format=‘docx’)
convert_response = words_api.convert_document(convert_request)
copyfile(convert_response, ‘output.docx’)
Please, how can I fix it?
@sophiasophia
We are investigating the issue. Meanwhile, can you please also share your input document?
Thanks!
Yes, I was trying to convert file like input.doc in zip belowinput.doc.zip (64.4 KB)
@sophiasophia
Thanks for sharing the input file. I have tested the scenario using the latest version of the Aspose.Words Cloud SDK for Python and have been unable to find any issues. Please ensure you are using the latest version of the Aspose.Words Cloud SDK for Python.
words_api = asposewordscloud.WordsApi(client_id,client_secret)
words_api.api_client.configuration.host='https://api.aspose.cloud'
inputFileName = 'C:/Temp/input.doc'
outputFileName = 'C:/Temp/output.docx'
#Convert Document without cloud storage
request = asposewordscloud.models.requests.ConvertDocumentRequest(document=open(inputFileName, 'rb'), format='docx')
result = words_api.convert_document(request)
open(outputFileName,'wb').write(result)
@sophiasophia I am experiencing the same issue all of a sudden. This was working fine a couple of days ago. Here is my code:
from asposewordscloud import WordsApi
from asposewordscloud.models.requests import ConvertDocumentRequest
client_id ='MASKED'
client_secret = 'MASKED'
input_file_name = 'CV184599_SOLER-Rémi_Turnover-it.doc'
words_client = WordsApi(client_id=client_id, client_secret=client_secret)
words_client.api_client.configuration.host='https://api.aspose.cloud'
doc_file = open(input_file_name, "rb")
request = ConvertDocumentRequest(document=doc_file, format="docx")
docx_content = words_client.convert_document(request=request)
And my file (uploaded as a zip since .doc is not allowed): input.zip (20.1 KB)
I am on the latest version of the python sdk
Stack trace: image.png (116.3 KB)
@jasper.madrone
I have tested the conversion using the Aspose.Words Cloud SDK for Python 23.7.0 with Python 3.9.2 and was unable to notice the reported issue. Please confirm your SDK and Python versions.
output.docx (28.9 KB)
Hi @tilal.ahmad, thanks for testing that out. I am on 23.7.0 for the python SDK and python 3.10.9
Ok on further examination, I added a print statement immediately before that line and I am getting this error:
{'error': 'invalid_client'}
I have checked and rechecked my client ID and secret. I am not sure why they are no longer being accepted.
Ok never mind, figured it out. I went past my free tier of usage this month
It would be useful to have that as an error that comes back instead of a KeyError
@jasper.madrone
It is good to know you have managed to resolve the issue. We will check the exception detail and update it accordingly.