Reputation: 147
"Unexpected character encountered while parsing value: <. Path '', line 0, position 0...."
I keep getting the error from the code below.
Sheet _TempSheet = _SmartsheetClient.SheetResources.GetSheet((long)_SheetID, null, null, null, null, null, null, null);
List<long> RowsToDeleteIDs = new List<long>();
foreach (Row _Row in _TempSheet.Rows)
{
RowsToDeleteIDs.Add((long)_Row.Id);
Console.WriteLine("Row: " + _Row.Id);
}
_SmartsheetClient.SheetResources.RowResources.DeleteRows((long)_SheetID, RowsToDeleteIDs, true);
Upvotes: 0
Views: 475
Reputation: 13500
I notice that you've tagged your question smartsheet-c#-sdk-v1 -- I haven't tested with the Smartsheet C# SDK v1, but the following code snippet (which includes a straight copy/paste of your code snippet, after setting up the connection and setting the Sheet ID) works fine with Smartsheet C# SDK v2. Perhaps try using the v2 SDK instead, and see if that resolves your issue?
// Setup connection
Token token = new Token();
token.AccessToken = "MY_TOKEN_VALUE";
SmartsheetClient _SmartsheetClient = new SmartsheetBuilder().SetAccessToken(token.AccessToken).Build();
// Set Sheet ID
long _SheetID = MY_SHEET_ID;
Sheet _TempSheet = _SmartsheetClient.SheetResources.GetSheet((long)_SheetID, null, null, null, null, null, null, null);
List<long> RowsToDeleteIDs = new List<long>();
foreach (Row _Row in _TempSheet.Rows)
{
RowsToDeleteIDs.Add((long)_Row.Id);
Console.WriteLine("Row: " + _Row.Id);
}
_SmartsheetClient.SheetResources.RowResources.DeleteRows((long)_SheetID, RowsToDeleteIDs, true);
Note: In the code above, replace MY_TOKEN_VALUE with the value of your access token, and replace MY_SHEET_ID with the value of your Sheet ID.
Upvotes: 1