When I tired accessing the sheet, I was getting invalid access token. But after changing the region [EU]. Now I'm able to access the Smartsheet's' data.
Code :
import smartsheet
# Replace with your actual API key and sheet ID
api_key = "Your API key" # Ensure this is a valid API key
sheet_id = valid sheet ID (num) # Replace with a valid sheet ID
# Initialize Smartsheet client for EU region with API key
client = smartsheet.Smartsheet(api_key, api_base="https://api.smartsheet.eu/2.0")
try:
# Retrieve sheet details
sheet = client.Sheets.get_sheet(sheet_id)
print("Columns in the sheet:")
for column in sheet.columns:
print(f"Name: {column.title}, ID: {column.id}")
except smartsheet.exceptions.ApiError as e:
print(f"Smartsheet API Error: {e}")
except Exception as e:
print(f"An error occurred: {e}")