Skip to main content
Question

How can I tell if my SDK or API calls are connected to my account?

  • November 18, 2024
  • 0 replies
  • 9 views

I’m runng a script on my local machine:

 

from boxsdk import Client, OAuth2
from boxsdk.exception import BoxAPIException

# Authenticate with Box
oauth2 = OAuth2(
    client_id='xxxxxxxxx',
    client_secret='xxxxxxxxx',
    access_token='xxxxxxx'  # Replace with OAuth token for production
)

client = Client(oauth2)

try:
    # Get the root folder
    root_folder_id = '0'
    folder = client.folder(folder_id=root_folder_id)

    # Print basic folder information
    folder_info = folder.get()
    print(f"Accessing folder: {folder_info.name} (ID: {folder_info.id})")
    print(f"Total item count in folder: {folder_info.item_collection['total_count']}")

    # Retrieve and list items in the folder with a higher limit
    items = list(folder.get_items(limit=1000))

    # Check if items are in the folder
    if not items:
        print("No items found in the root folder.")
    else:
        # Print details of all items in the folder
        for item in items:
            print(f"Item: {item.name} (Type: {item.type}, ID: {item.id})")

except BoxAPIException as e:
    print(f"An error occurred: {e}")

print("end script")



And I’m getting this output:

Accessing folder: All Files (ID: 0)
Total item count in folder: 0
No items found in the root folder.
end script




What am I doing wrong?  The box account is full of tons of files.  I should get back something. How can I trouble shoot this?

0 replies

Be the first to reply!

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings