收藏
回答

云函数发送订阅消息报错如何解决?



订阅模板信息如上图

测试用户已允许获取订阅消息

云函数代码如下

//config 
{
 "permissions": {
    "openapi": [
      "templateMessage.send"
    ]
  }
}
//测试发布订阅消息云函数
const cloud = require('wx-server-sdk')
cloud.init({
  env: 'ENV-ID',
})

// 云函数入口函数
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.subscribeMessage.send({
      touser: 'oTELJ5apZ7CE0663ONOemmq91UHc', // 订阅者的openid
      page: 'pages/taskList/taskList',
      data: {
        thing10: {
          value: 'test'
        },
        thing2: {
          value: 'test'
        }
      },
    })
    console.log(result)
    return result
  } catch (err) {
    console.log(err)
    return err
  }
}


云函数日志

返回结果
{"errCode":-501007,"errMsg":"subscribeMessage.send:fail Invalid request param"}
日志
START RequestId: 64671a33-d7cd-11ea-a16a-5254002665ac
Event RequestId: 64671a33-d7cd-11ea-a16a-5254002665ac
2020-08-06T10:12:54.167Z  { Error: errCode: -501007 invalid parameters | errMsg: subscribeMessage.send:fail Invalid request param
    at callGeneralOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:375:19)
    at 
    at process._tickCallback (internal/process/next_tick.js:188:7)
  errCode: -501007,
  errMsg: 'subscribeMessage.send:fail Invalid request param' }
END RequestId: 64671a33-d7cd-11ea-a16a-5254002665ac
Report RequestId: 64671a33-d7cd-11ea-a16a-5254002665ac Duration:46ms Memory:256MB MemUsage:35.800781MB


如何解决?


回答关注问题邀请回答
收藏

1 个回答

  • 恒
    2020-08-06

    2020-08-06
    有用
    回复
登录 后发表内容
问题标签