adamcoolcat
adamcoolcat

Reputation: 105

Copy A Sheet in Smartsheet using Python API

I was attempting to copy a sheet with the python API, but every time I do so, it only includes the formatting (column names and number of rows), but I would like it to include the data. Is there any way I can do this? I have tried it with a template as well and the same thing happens it creates a new sheet but it doesn't have any of the data.

Edited code after the question was answered:

inc_list = ['data'] # you can add other parameters here, separated by a comma
response = ss_client.Sheets.copy_sheet(
sheetID,                               # sheet_id
ss_client.models.ContainerDestination({
'destination_type': 'folder',               # folder, workspace, or home
'destination_id': folderID,         # folder_id
'new_name': cellValue,
}),
include=inc_list
)

Upvotes: 1

Views: 1192

Answers (1)

J. Craig Williams
J. Craig Williams

Reputation: 410

There is an include parameter that needs to be added.

For example,

    inc_list = ["data"]
    sht = SmSh.Sheets.copy_sheet(src_sheet_id,
                                 SmSh.models.ContainerDestination({
                                 "destination_type": "folder",
                                 "destination_id": dest_id,
                                 "new_name": new_sheet_name}),
                                 include=inc_list
                                 )

Note that dest_id and new_sheet_name are also arguments set above this code snippet and not shown.

A complete list of the include parameters is shown in the SDK docs: https://smartsheet-platform.github.io/api-docs/?python#copy-sheet

Craig

Upvotes: 1

Related Questions