jotarami92
jotarami92

Reputation: 13

How to delete tasks using smartsheet api and google apps script

I'm developing a small script for operational tasks, and I need to delete rows from smartsheet using the API but I don't know what I am exactly doing wrong. This is my code:

function deleteRow(rowId){
  var url = "https://api.smartsheet.com/2.0/sheets/"+sheet_id+"/rows";
  Logger.log(rowId);
  var options = {
    "headers": {"authorization": "Bearer 4qg7ryl8bugi51ziuuq6a9mey0"},
    "parameters": {"ids": "6469321685788548"},
    "method": "delete", 
    "contentType": "application/json",
    muteHttpExceptions: true
  }; 
  var response = UrlFetchApp.fetch(url, options); 
  Logger.log(response);
}

sheet_id is where tasks are written. rowId is what i want to delete. The error I am getting is:

[17-12-27 12:28:12:149 CET] {
  "errorCode" : 1009,
  "message" : "A required parameter is missing from your request: ids.",
  "refId" : "5er1e7ha2p0n"
}

Anybody knows how to make it work?

Thanks in return.

Upvotes: 1

Views: 373

Answers (2)

daveskull81
daveskull81

Reputation: 637

Looking here it doesn't appear that the options object you provide to UrlFetchApp.fetch() has a parameters attribute. Have you tried concatenating the query string for the row id you want to delete to the url variable you are creating?

var url = "https://api.smartsheet.com/2.0/sheets/"+sheet_id+"/rows?ids="+rowId

Upvotes: 1

Vignesh R
Vignesh R

Reputation: 609

Deletes one or more rows from the Sheet specified in the URL.

DELETE /sheets/{sheetId}/rows?ids={rowId1},{rowId2},{rowId3}

rowId is required parameter. So you need specify the correct rowId of which row should delete. Issue is related with your rowId. Kindly send the valid rowId to delete the row in sheet.

Upvotes: 0

Related Questions