I’m getting this error:
Blockquote
/usr/local/bin/python3 “/Users/ibrun/Library/Mobile Documents/com~apple~CloudDocs/programming/pdf editor/main.py”
Traceback (most recent call last):
File “/Users/ibrun/Library/Mobile Documents/com~apple~CloudDocs/programming/pdf editor/main.py”, line 20, in
response = pdf_api.post_document_text_replace(remote_name, text_replace_list)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asposepdfcloud/apis/pdf_api.py”, line 23961, in post_document_text_replace
(data) = self.post_document_text_replace_with_http_info(name, text_replace, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asposepdfcloud/apis/pdf_api.py”, line 24040, in post_document_text_replace_with_http_info
return self.api_client.call_api(’/pdf/{name}/text/replace’, ‘POST’,
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asposepdfcloud/api_client.py”, line 411, in call_api
return self.__call_api(resource_path, method,
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asposepdfcloud/api_client.py”, line 206, in __call_api
raise error
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asposepdfcloud/api_client.py”, line 189, in __call_api
response_data = self.request(method, url,
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asposepdfcloud/api_client.py”, line 454, in request
return self.rest_client.POST(url,
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asposepdfcloud/rest.py”, line 288, in POST
return self.request(“POST”, url,
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asposepdfcloud/rest.py”, line 250, in request
raise ApiException(http_resp=r)
asposepdfcloud.rest.ApiException: (500)
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({‘Date’: ‘Tue, 01 Feb 2022 23:19:56 GMT’, ‘Content-Type’: ‘application/json; charset=utf-8’, ‘Transfer-Encoding’: ‘chunked’, ‘Connection’: ‘keep-alive’, ‘Server’: ‘Kestrel’, ‘Strict-Transport-Security’: ‘max-age=2592000’})
HTTP response body: {“RequestId”:“49bb624a-3edb-430f-8eed-8cf21c2464a0”,“Error”:{“Code”:“internalError”,“Message”:“Object reference not set to an instance of an object.”,“Description”:“Operation Failed. Internal error.”,“DateTime”:“2022-02-01T23:19:56.1836017Z”,“InnerError”:null}}
Blockquote
My code is the next one:
import os
import asposepdfcloud
from asposepdfcloud.apis.pdf_api import PdfApi
pdf_api_client = asposepdfcloud.api_client.ApiClient(
app_key=“xxxxx”,
app_sid=‘xxxxx’)
pdf_api = PdfApi(pdf_api_client)
filename = ‘Binder1.pdf’
remote_name = ‘Brinder1Results3.pdf’
pdf_api.upload_file(remote_name,filename)
text_replace1 = asposepdfcloud.models.TextReplace(old_value=‘Name’,new_value=‘David Aviles’,regex=‘true’)
text_replace2 = asposepdfcloud.models.TextReplace(old_value=‘n_rut’,new_value=‘19…915-0’,regex=‘true’)
text_replace_list = asposepdfcloud.models.TextReplaceListRequest(text_replaces=[text_replace1])
response = pdf_api.post_document_text_replace(remote_name, text_replace_list)
print(response)
pdf_api.download_file(remote_name, ‘results/’ + remote_name)
Any ideas?
And, in the other hand, how I suppouse to download the file with the modifications done?