云函数中定时发送模版消息失败。
小程序端手动调用云函数中的发送模版消息是可以的,
但云函数加上定时触发器自动发送模版消息报错。
报错信息
{"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"errCode: -501007 invalid parameters | errMsg: templateMessage.send:fail Invalid request param"}
日志
START RequestId: 3fbaefb3-e734-11e9-beb7-525400dee61a
Event RequestId: 3fbaefb3-e734-11e9-beb7-525400dee61a
2019-10-05T05:52:00.701Z _openid:odomL5TLxa9Eg38t5L6nu67wQ1iU formID: c126f6614b7241b78572777b226904a4
Error: errCode: -501007 invalid parameters | errMsg: templateMessage.send:fail Invalid request param
at new CloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:6366:28)
at Object.<anonymous> (/var/user/node_modules/wx-server-sdk/index.js:421:35)
at step (/var/user/node_modules/tslib/tslib.js:136:27)
at Object.next (/var/user/node_modules/tslib/tslib.js:117:57)
at fulfilled (/var/user/node_modules/tslib/tslib.js:107:62)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
END RequestId: 3fbaefb3-e734-11e9-beb7-525400dee61a
Report RequestId: 3fbaefb3-e734-11e9-beb7-525400dee61a Duration:160ms Memory:256MB MaxMemoryUsed:29.660156MB
_openid是通过查询用户表获得填写进去的。