这是我的Python面。
...
SCRIPT_ID = '<script id>'
creds = GetGoogleCredentials()
gscripts = build( 'script', 'v1', credentials = creds )
# Create an execution request object.
request = {
"function": "test1",
"devMode": True,
"parameters": [{
"1": "hi",
"3": "bye",
"a5": "yes"
}]
}
# Make the API request.
response = gscripts.scripts().run(
body = request,
scriptId = SCRIPT_ID
).execute()
print( response )
这是Apps脚本端:
function test1( event ) {
Logger.log( event );
Logger.log( event[1] );
Logger.log( event["3"] );
Logger.log( event["a5"] );
}
以及记录器中的输出:
[20-01-16 16:34:21:530 PST] {1=hi, 3=bye, a5=yes}
[20-01-16 16:34:21:531 PST] undefined
[20-01-16 16:34:21:531 PST] undefined
[20-01-16 16:34:21:532 PST] yes
我一直试图弄清楚我在做什么错,为什么当我尝试索引它时,即使记录器能够读取值,对象仍返回未定义的原因。使用数字作为对象键似乎与处理不当有关。我确定起初我在做一些愚蠢的事情,但这是我缩小范围的测试用例。