4

When I try to get the id array from the get.folder() call (by using folder = folder.sheets.id), I get the answer: "AttributeError: 'TypedList' object has no attribute 'id'" I'm not sure what function to call in python to get the array of sheet ids in the folder.

I am trying to do this with the python smartsheet sdk, but I am not sure exactly how to format it.

inc_list = ['all'] # you can add other parameters here, separated by a comma
 response = ss_client.Folders.copy_folder(
  folderID,                           # folder_id
  ss_client.models.ContainerDestination({
    'destination_id': destinationID,
    'destination_type': 'folder',
    'new_name': cellValue
  }),
include=inc_list
)

copiedFolderID = response.result.id

folder = ss_client.Folders.get_folder(
  copiedFolderID)       # folder_id 

newFolder = folder.sheets.id

print (newFolder)

Also thanks for helping answer my questions, I really appreciate it.

1

2 Answers 2

3

folder.sheets is an array. The reason you're getting an error is because there is no id attribute at the array level - you need to look at the individual elements inside the array.

Take a look at the API docs to get an example of what you'd receive.

sheet_ids = []
for sheet in folder.sheets
    sheet_ids.append(sheet.id)
print(sheet_ids)
Sign up to request clarification or add additional context in comments.

1 Comment

It worked! Thank you so much, now I can get to work on creating the loop for editing the names of all the documents.
1

To get a list of the sheetIds for sheets in a folder, your Python would look something like this.

my_folder = ss_client.Folders.get_folder(folder_id)

for sheet in my_folder.sheets:
    print(sheet.id)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.