I cannot get the PUT method to work. What is wrong with my Google Script code ?

I cannot get the PUT method to work. It does not error but it also does not update the sheet. The same code framework will add columns (with a POST), and pull back data (with a GET)..but it will not put data into the sheet.

Tried it with Content-Type in the Headers section and Options, with out single quotes and with,..all kinf\ds of variations but no good.

var headers3 = {ย  ย  ย  ย  ย  ย  "Authorization" : "Bearer " + basicToken,ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  };
var url3 = 'https://api.smartsheet.com/2.0/sheets/' + googleSheetData1[x][0]+ '/rows' ;ย 

var options3 = {
ย ย  'method': "PUT",ย 

ย  ย 'content-type':'application/json',ย 

ย  ย  'headers': headers3,

ย  ย  'muteHttpExceptions' : true,ย 

ย  ย  'payload': JSON.stringify([{"id":rowidx,"cells":[{"columnid":colidx,"value":"kevintest"}]}])ย  ย 

ย  ย  ย  } ย  ย 

try{ ย ย  ย  ย  ย  ย  ย  var response3 = UrlFetchApp.fetch(encodeURI(url3),options3);

Answers

  • Isaac A.
    Isaac A. Employee

    Hi @KTO!

    I recommend using Postman to test your API calls. This way, you can verify whether the issue lies within the API call itself or your script code. Itโ€™s a good method to troubleshoot and pinpoint the problem more efficiently.

    Please note that Smartsheet Support doesnโ€™t handle inquiries related to custom scripts or coding issues.

    In the meantime, here is our API Documentation which might be helpful. Also, if you donโ€™t get a response from the community, I suggest checking out Stack Overflow where other developers using Smartsheet can provide insights.

    I hope this helps!

    Cheers,

    Isaac.

    Need more information? ๐Ÿ‘€ |Help and Learning Center
    ใ“ใ‚“ใซใกใฏ (Konnichiwa), Hallo, Hola, Bonjour, Olรก, Ciao! ๐Ÿ‘‹ |Global Discussions

NEW Smartsheet API Documentation - bookmark the updated link! https://developers.smartsheet.com