Reputation: 127
Code I've run v1:
var G = SpreadsheetApp.getActiveSheet();
var Resp1 = UrlFetchApp.fetch(url1, parameters);
var parResp1 = JSON.parse(Resp1);
var k = parseInt(parResp1.time);
G.getRange("B5").setValues(k);
Code v2 Change replaces 4th line with:
var k = JSON.stringify(parResp1.time);
After I run my Code I get this error message
Cannot find method setValues(number). (line 27, file "Code")
The Value that is returned is a number but I don't understand why it doesn't see it as one.
What could be going on?
Upvotes: 1
Views: 4673
Reputation: 46794
While the other answer is correct, it doesn't explain the reason why you are having this error.
As mentioned in the documentation about setValues()
, the argument for setValues()
must be a 2 dimensions array (an array of arrays) either built from scratch or captured using getValues()
.
see The doc below :
By the way, the funny thing is that the title of your post uses setValue()
without S
while your code has the problematic S
...
Upvotes: 2
Reputation: 3078
If you only want to update a single cell, in your case getRange("B5") you should use setValue, not setValues
setValues would be used in the case where you want to set the values for a range between two points such as "A1:B2"
Upvotes: 2