Why do I get an UnexpectedRequestError (, None) when trying to use the SmartSheet API?

  Kiến thức lập trình

I want to list the columns of a sheet so I know how columns are referenced vs how they appear in the smarsheet but I keep getting this error.

UnexpectedRequestError (<PreparedRequest [GET]>, None) at action = client.Sheets.get_columns(sID, include_all=True)

I am using VScode and python 3.7 since this is what my work allows.

I installed the VScode extensions Python, Jupyter and Intellicode.

I also had to run pip install urllib3==1.26.6 to deal with another error.

I am not sure if the error is in the code or how I set-up VScode and am new to API entirely.

Any insight would be greatly appreciated.

Here is what I have tried so far.

import smartsheet as ss
import os
import logging

# specify access token --unique for each user
os.environ['SMARTSHEET_ACCESS_TOKEN'] = xxxx

# client obj must point to .__gov_base__
client = ss.Smartsheet(api_base=ss.__gov_base__)

# set logger to critical events
logging.getLogger('smartsheet').setLevel(logging.CRITICAL)

# raise exceptions for API errors
client.errors_as_exceptions(True)

# define sheet ID
sID = xxx

action = client.Sheets.get_columns(sID, include_all=True)
columns = action.data
#print(f"Data has been saved to {csv_file}")
for col in columns:
    print(col.id)
    print(col.title)
    print('')

I used to receive this ImportError! Could not load api or model class __iter__ in addtion to the error when I used

try:
    action = client.Sheets.get_columns(sID, include_all=True)
    print(action)
except Exception as e:
    print(f"Error: {e}")

But now I do not see that as part of the error.

I expect the code to simply print all of the column ids and titles but I have not been able to get it to work at all.

New contributor

iWanB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT