Smartsheet API Delete Row Function Error
Hi,
When I run a code to delete multiple columns in a sheet >500. It run successfully once, the second try gave an error :
Response: { status: 414 Request-URI Too Large content: { << text/html; charset=iso-8859-1 content type suppressed >> }
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The code below reads a sheet and deletes data below the 13th row.
def delete_data():
row_ids = [row.id for row in sheet.rows]
row_ids = row_ids[13:]
ss_client.Sheets.delete_rows(
sheet_id,
row_ids
)
Do you have any ideas what went wrong and how do I fix it.
Comments
-
Hello—
I'm wondering if this is an issue with the JSON decoder you're using?
If you're using the python, try updating to the latest version or at least try a 3.7.x build.
You might also make sure you're not using something like pycurl and just stick to the json library that's built into python OR try a library like requests.
If the above doesn't fix the issue, please contact our Support team and we'll troubleshoot the issue with you.
-
Facing the similar issue when there are too many lines
Response: {
status: 429 Too Many Requests
content: {
{
"errorCode": 4003,
"message": "Rate limit exceeded.",
"refId": "v0y2h98ghltf"
}
}
Response: {
status: 429 Too Many Requests
content: {
{
"errorCode": 4003,
"message": "Rate limit exceeded.",
"refId": "17gmal7fscyaa"
}
}
Response: {
status: 429 Too Many Requests
content: {
{
"errorCode": 4003,
"message": "Rate limit exceeded.",
"refId": "1qt2zmi121qjl"
}
} -
Hi Wdjameh,
Deleting rows by chunks of 200 does the trick for me. Measured performance: deleting 5000 rows (max sheet size per Sept 2019) by chunks of 200 takes 17 seconds.
Python code below.
Hope that helps!
##########################################
my_smartsheet_id=<YourSmartsheetIDHere>
sheet = smart.Sheets.get_sheet(my_smartsheet_id)
# DELETE ALL ROWS
print ("Deleting all rows in Smartsheet...")
row_list_del=[]
for row in sheet.rows:
row_list_del.append(row.id)
#Delete rows to sheet by chunks of 200
if len(row_list_del) > 199:
smart.Sheets.delete_rows(my_smartsheet_id,row_list_del)
row_list_del = []
# Delete remaining rows
if len(row_list_del)>0:
smart.Sheets.delete_rows(my_smartsheet_id,row_list_del)##########################################
-
using smartsheet-python-sdk==2.105.0 I also got the error: Request-URI Too Large
thanks for the code idea @dbgeneve !
I had 3647 rows to delete. Implementing the chunks by 200 rows deletion approach, execution time took about 67 seconds.
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.6K Get Help
- 433 Global Discussions
- 136 Industry Talk
- 465 Announcements
- 4.9K Ideas & Feature Requests
- 143 Brandfolder
- 146 Just for fun
- 63 Community Job Board
- 466 Show & Tell
- 32 Member Spotlight
- 2 SmartStories
- 298 Events
- 36 Webinars
- 7.3K Forum Archives