API - C# - Delete rows from a specific index
Hi there,
I'm newbie on Smartsheet. I am working on integration of data from another system to Smartsheet through API.
The requirement is that we need to delete all rows from the fourth row to the last one of sheet then adding the new data into sheet every time we run API.
I've already implemented adding row data into sheet smoothly. However, the stuck is deleting from the fourth row.
I wonder if there is any way to delete data from a specific row through API. My project is working on the C#.
I would appreciate so much for those who can help me get out of this issue
Many thanks in advance!
Best Answer
-
Hi @HoaLT
Are you looking to clear cell details from row 4 or fully delete out the rows?
Here's the Delete Row information from the API Documentation: https://smartsheet.redoc.ly/tag/rows#operation/delete-rows
There's C# details on the right side. You may also want to post in the StackOverflow community for help with C#.
If you're receiving errors, I would recommend reaching out to Smartsheet Support with your full code and the Sheet ID.
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Answers
-
I 've figured out on my own the following function in NodeJs
function resetSheet (sheetId) {
// Get sheet
smartsheet.sheets.getSheet({sheetId})
.then(function(sheetInfo) {
const rowIdList = sheetInfo.rows.map(item => item.id);
return rowIdList;
})
.then(data => {
const deleteIds = data.splice(3);
deleteIds.forEach(rowid => {
smartsheet.sheets.deleteRow({
sheetId: sheetId,
rowId: rowid
})
.then(function(results) {
console.log(results);
})
.catch(function(error) {
console.log(error);
});
})
})
.catch(function(error) {
console.log(error);
});
}
It works but sometimes, it does not delete all rows from the 4th to the end along with alerting the following error
errorCode=4004, message=Request failed because sheetId XXX is currently being updated by another request that uses the same access token. Please retry your request once the previous request has completed
Do i missed anything?
And is there any better solution we can deal with it? Solution with C# would be appreciated so much
Many thanks!
-
Hi @HoaLT
Are you looking to clear cell details from row 4 or fully delete out the rows?
Here's the Delete Row information from the API Documentation: https://smartsheet.redoc.ly/tag/rows#operation/delete-rows
There's C# details on the right side. You may also want to post in the StackOverflow community for help with C#.
If you're receiving errors, I would recommend reaching out to Smartsheet Support with your full code and the Sheet ID.
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 140 Industry Talk
- 472 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 496 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives