We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

Aspose.PDF Cloud API initialization error in python

pdfapi is not working as intended.

pdf_api_client = asposepdfcloud.api_client.ApiClient(xxxx, xxxx)

IDs and secret client ids are generated in the dashboard. It gives me the following error:

" pdf_api = asposepdfcloud.PdfApi(‘xxxx’, ‘xxxx’)
TypeError: init() takes from 1 to 2 positional arguments but 3 were given"


We are sorry for the inconvenience. There is some issue with the sample code. You need to pass Client secret as the first argument instead of Client id. Please check the sample working example.

import os
import asposepdfcloud
from asposepdfcloud.apis.pdf_api import PdfApi

# Get App key and App SID from https://cloud.aspose.com
pdf_api_client = asposepdfcloud.api_client.ApiClient('xxxxxxxxxxxxxxxxxxxxxxxxxx','xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx')

pdf_api = PdfApi(pdf_api_client)
filename = '4pages.pdf'
remote_name = '4pages.pdf'
output_file= '4pages.xml'
#upload PDF file to storage
#Covert PDF to XML and save in storage

I got past the client assignment. thank you, using your code above, I am trying to upload a sample pdf file to my internal storage, I provided, the secret_id, and the client id as part of the argument above. and got the following error message

Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Tue, 12 Oct 2021 06:33:05 GMT', 'Content- 
Type': 'application/json; charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 
 'AWSALB=NxjH42IvYTk8ExA4TeS5wg0OQTjtUs8r+bxBWBMQO19UqAQuoeH653MS+nLsr3DLVC6Fe4ToeKzY6bmi6rzTh5iKL9kOCyeoZDpju8weENkasRwkEarWbntdHEpm; Expires=Tue, 19 Oct 2021 06:33:05 GMT; Path=/, AWSALBCORS=NxjH42IvYTk8ExA4TeS5wg0OQTjtUs8r+bxBWBMQO19UqAQuoeH653MS+nLsr3DLVC6Fe4ToeKzY6bmi6rzTh5iKL9kOCyeoZDpju8weENkasRwkEarWbntdHEpm; Expires=Tue, 19 Oct 2021 06:33:05 GMT; Path=/; SameSite=None; Secure', 'Cache-Control': 'no-store, no-cache, max-age=0', 'Pragma': 'no-cache', 'X-Robots-Tag': 'noindex, nofollow'})
HTTP response body: {"error":"invalid_client"}"

here is the source code:

pdf_api_client = asposepdfcloud.api_client.ApiClient(app_sid, app_key)
pdf_api = PdfApi(pdf_api_client)
filename = 'shapes2.pdf'
remote_name = 'shapes2.pdf'
response = pdf_api.upload_file(remote_name,filename)


Please pay attention to my above reply. The first argument of ApiClient is client secret as following.

pdf_api_client = asposepdfcloud.api_client.ApiClient(app_key,app_sid)

yes, that is what I did already, app_sid = app secret id and the app_key = client id.

I already updated the code, with the following format but still yields the same result:
pdf_api_client = asposepdfcloud.api_client.ApiClient('52xxxxxxxxxxxxxxxxxxxxxxxxxx1127', 'axxxxxx3-xxxx-xxxx-xxxx-axxxxxxxxxxe')

this is based on the credentials I got based on the tutorial
aspose_client_credentials.png (4.9 KB)


The sample code is working fine at my end. Please double check that you are using the latest version of Aspose.PDF Cloud SDK for Python and you have copied the credentials correctly from aspose.cloud dashboard. Hopefully it will resolve the issue. Otherwise, please share your credentials with me via a private message.


I got it working now, when I regenerated my tokens

1 Like