I’m trying to use word document protect api using python.
Kindly help me use the document protection feature. Urgent.
Getting the the following error:
ubuntu@mehulj:~$ python3 /home/ubuntu/Desktop/curl/aspose.py
Traceback (most recent call last):
File “/home/ubuntu/Desktop/curl/aspose.py”, line 27, in
words_api.upload_file(asposewordscloud.models.requests.UploadFileRequest(open(filename, ‘rb’), “”, None))
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/apis/words_api.py”, line 22519, in upload_file
data = self.upload_file_with_http_info(request, **kwargs) # noqa: E501
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/apis/words_api.py”, line 22574, in upload_file_with_http_info
collection_formats=http_params[‘collection_formats’]))
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/api_client.py”, line 400, in call_api
_preload_content, _request_timeout)
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/api_client.py”, line 162, in __call_api
self.request_token()
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/api_client.py”, line 146, in request_token
_request_timeout=None)
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/api_client.py”, line 442, in request
body=body)
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/rest.py”, line 287, in POST
body=body)
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/rest.py”, line 240, in request
raise ApiException(http_resp=r)
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/rest.py”, line 318, in init
self.init_error_response(json.loads(http_resp.data))
File “/home/ubuntu/.local/lib/python3.7/site-packages/asposewordscloud/rest.py”, line 340, in init_error_response
self.body = WordsApiErrorResponse(json_object[“RequestId”], self.init_error(json_object[“Error”]))
KeyError: ‘RequestId’
My Code :
import os
import asposewordscloud
import asposewordscloud.models.requests
from asposewordscloud.apis import WordsApi
import asposewordscloud.models
from asposewordscloud.models import ProtectionRequest
from asposewordscloud.rest import ApiException
import asposewordscloud.rest
client_id=“xyz”
client_secret= “xyz”
words_api = WordsApi(client_id, client_secret)
filename= “/home/ubuntu/Desktop/curl/Words.docx”
body = ProtectionRequest(password=“hello”,new_password=‘123’, protection_type=“AllowOnlyRevisions”)
words_api.upload_file(asposewordscloud.models.requests.UploadFileRequest(open(filename, ‘rb’), “”, None))