收藏
回答

订阅消息发送用户收到了,但是调用返回出错,请问是什么原因?

订阅消息请求参数: {

  "touser": "owdMa5EAUynaORgidxALOuqrfjhc",

  "template_id": "DXMhbrFhf8EYN8Vh3LwfnprXLAgo2Or4crnnd_cexYk",

  "page": "pages/guild-war/user-login",

  "data": {

    "thing1": {

      "value": "灵魂角鹿"

    },

    "number4": {

      "value": 13

    },

    "time3": {

      "value": "2026-02-03 19:20:29"

    }

  }

}

// 发送订阅消息
const sendResult = await cloud.openapi.subscribeMessage.send({
    touser: openid,
    template_id: notifyType.templateId,
    page: 'pages/guild-war/user-login',
    data: content
})

2026-02-03T11:20:30.125Z  通知处理错误: {

  message: 'openapi.subscribeMessage.send:fail -501001 resource system error. Unexpected token { in JSON at position 2',

  stack: 'Error: openapi.subscribeMessage.send:fail -501001 resource system error. Unexpected token { in JSON at position 2\n' +

    '    at toSDKError (/var/user/node_modules/wx-server-sdk/index.js:8175:19)\n' +

    '    at Object.returnAsFinalCloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:8146:12)\n' +

    '    at callWXOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:2513:27)\n' +

    '    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +

    '    at async sendMessage (/var/user/index.js:313:40)\n' +

    '    at async handleBossRefresh (/var/user/index.js:580:37)\n' +

    '    at async exports.main (/var/user/index.js:650:28)',

  code: undefined,

  time: '2026-02-03T11:20:30.125Z'

}

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

2 个回答

  • 哄哄
    哄哄
    02-04

    wx-server-sdk 把这个版本改成3.0.1再试一试

    02-04
    有用
    回复 2
    • Sun45
      Sun45
      02-04
      谢谢,但是用的是3.0.1版本
      02-04
      回复
    • Sun45
      Sun45
      02-06
      谢谢,把版本从^3.0.1改为3.0.1可以了,我是自学的,所以并不清楚这两种的区别。
      02-06
      回复
  • 智能回答 智能回答 本次回答由AI生成
    02-03
    有用
    回复 1
    • Sun45
      Sun45
      02-04
      错误信息:


      2026-02-04T10:47:33.955Z  通知处理错误: {

        message: 'openapi.subscribeMessage.send:fail -501001 resource system error. Unexpected token { in JSON at position 2',

        stack: 'Error: openapi.subscribeMessage.send:fail -501001 resource system error. Unexpected token { in JSON at position 2\n' +

          '    at toSDKError (/var/user/node_modules/wx-server-sdk/index.js:8175:19)\n' +

          '    at Object.returnAsFinalCloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:8146:12)\n' +

          '    at callWXOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:2513:27)\n' +

          '    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +

          '    at async sendMessage (/var/user/index.js:283:36)\n' +

          '    at async handleBossRefresh (/var/user/index.js:551:37)\n' +

          '    at async exports.main (/var/user/index.js:621:28)',

        code: undefined,

        time: '2026-02-04T10:47:33.955Z'

      }
      02-04
      回复
登录 后发表内容