0

I am trying to move a row from one sheet to another sheet, can someone help me with this? please see my code below:

from smartsheet import sheets, models

source_sheet_id = 123456789 #int
destination_sheet_id = 987654321 #int

sheets.Sheets.move_rows(
    source_sheet_id,
    models.CopyOrMoveRowDirective({
        'row_ids': [row_id],
        'to': models.CopyOrMoveRowDestination({
            'sheet_id': destination_sheet_id
            })
        })
)

Thank you in advance

  • Can you provide more information on this? What are the results when you run this code? Do you get an error? If so, what is the error? What do you expect to happen when you run this? This code looks to be pretty identical to the example in the Smartsheet API docs except you don't look to be setting the row ids. Providing more information on what is happening will make it easier to assist. – daveskull81 Oct 17 '19 at 03:22
  • Error: `'sheet_id': destination_sheet_id TypeError: move_rows() missing 1 required positional argument: 'copy_or_move_row_directive_obj'` I would like to move one row from a sheet to a different sheet, this row should be added to the end of the destination file. – Esteban_ga Oct 18 '19 at 12:19
  • Is all of your code for this in the question? Did you create a Smartsheet client? It would look like this: smartsheet_client = smartsheet.Smartsheet(access_token) – daveskull81 Oct 18 '19 at 20:31
  • No, it is not, my code is huge but this part is the one that I am trying to use to find a row and then move it to the end of a different sheet. No, I have not created a Smartsheet client – Esteban_ga Oct 22 '19 at 10:03
  • I would suggest creating a Smartsheet client and providing the access token. Without the access token it won't be able to authenticate you and determine if you have correct permissions to the sheets in question. Then use the client to make the requests. That is the documented way of using the SDK instead of just importing the package. – daveskull81 Oct 23 '19 at 17:54

1 Answers1

0

You can use below code to move rows from one sheet to another:

response = smartsheet_client.Sheets.move_rows(
  4583173393803140,           # sheet_id of rows to be moved
  smartsheet.models.CopyOrMoveRowDirective({
    'row_ids': [145417762563972, 8026717110462340],
    'to': smartsheet.models.CopyOrMoveRowDestination({
      'sheet_id': 2258256056870788
    })
  })
)

you can check out available documentation here: Smartsheet python doc

msusare
  • 473
  • 2
  • 7