DoGet与多参数未被识别

我目前正在尝试将Lua脚本连接到GS WebApp。 连接正常,但由于我对GScripting的知识不足,我不确定为什么它不能正确保存我的数据。

在Lua侧,我只是传递了一个硬编码的随机名称和简单的数字用户ID。

local HttpService = game:GetService("HttpService")
local scriptID = scriptlink
local WebApp

local function updateSpreadSheet ()

    local playerData = (scriptID .. "?userid=123&name:Jhon Smith")
    WebApp = HttpService:GetAsync(playerData)
end

do
    updateSpreadSheet()
end

在Google脚本方面,我只在最后一行保存数据,然后添加userid和name的值。

function doGet(e) {
  console.log(e)
 // console.log(f)
  callName(e.parameter.userid,e.parameter.name);
}

function callName(userid,name) {
  // Get the last Row and add the name provided
  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.getRange(sheet.getLastRow() + 1,1).setValues([userid],[name]);
}

然而,脚本保存的仅仅是名称,忽略了userid,原因尚未发现。

点赞
用户8404453
用户8404453

setValues() 需要一个二维数组,范围的维度应该对应于该数组。脚本只得到了一个 1 x 1 的范围,并且 setValues 的参数不是二维数组。修复语法或者使用appendRow

sheet.getRange(sheet.getLastRow() + 1,1,1,2).setValues([[userid,name]]);
//或者
sheet.appendRow([userid,name])

参考文献:

2020-04-16 13:21:34