我也遇到类似问题, 求解 {"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"TypeError: Converting circular structure to JSON\n --\u003e starting at object with constructor 'ClientRequest'\n | property 'socket' -\u003e object with constructor 'TLSSocket'\n --- property '_httpMessage' closes the circle\n at JSON.stringify (\u003canonymous\u003e)\n at callback (/var/runtime/node12/CallbackContext.js:31:23)\n at /var/runtime/node12/CallbackContext.js:81:16\n at /var/runtime/node12/Runtime.engine.js:237:13\n at processTicksAndRejections (internal/process/task_queues.js:97:5)","statusCode":430}
使用消息订阅模板,发送消息后,有报错使用的数据如下: data:{ 'thing7':{'value':event.name}, 'thing8':{'value':event.zj_staff}, 'thing6':{'value':event.visit_reason}, 'phrase2':{'value':event.audit}, 'thing3':{'value':event.other}, }, #上面的值,都是字符串,没有数字,报错Do not know how to serialize a BigInt\n at JSON.stringify 用了两个不同模板,其中一个模板ID为,_LXTR-Y-XUDAO1bnz-h4DV5LkDvoNrFk3aqPSEPwai0。 报错相同信息如下: "errorCode":1,"errorMessage":"user code exception caught","stackTrace": "TypeError: Do not know how to serialize a BigInt\n at JSON.stringify (\u003canonymous\u003e)\n at callback (/var/runtime/node12/CallbackContext.js:31:23)\n at /var/runtime/node12/CallbackContext.js:81:16\n at /var/runtime/node12/Runtime.engine.js:237:13\n at processTicksAndRejections (internal/process/task_queues.js:97:5)","statusCode":430}
2023-07-03 try { var datax = { "template_id": "9f_ioRXJ1LwX5r123FzIwUAVEr_QgY4VZNsFzvZOE_Y", "sn": status_report[index].onenet_id, "page": "page/map/map", "to_openid_list": [ status_report[index].openid ], "modelId": "DD1EnNuPXeaKypIflweYvw", "lang": "zh_CN", "data": { "character_string2": { "value":status_report[index].onenet_id }, "time1": { "value":alarm_time } } } var cloudlink = "https://api.weixin.qq.com/cgi-bin/message/device/subscribe/send" const resp = await Axios.post(cloudlink, datax) return resp console.log(resp) } catch (err) { console.log(err) return err } 帮忙大神看看代码, 这段代码本地云函数调试是成功的, 但是云端部署后报错 {"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"TypeError: Converting circular structure to JSON\n --\u003e starting at object with constructor 'ClientRequest'\n | property 'socket' -\u003e object with constructor 'TLSSocket'\n --- property '_httpMessage' closes the circle\n at JSON.stringify (\u003canonymous\u003e)\n at callback (/var/runtime/node12/CallbackContext.js:31:23)\n at /var/runtime/node12/CallbackContext.js:81:16\n at /var/runtime/node12/Runtime.engine.js:237:13\n at processTicksAndRejections (internal/process/task_queues.js:97:5)","statusCode":430}
API sendHardwareDeviceMessage 是否支持云函数调用云函数中调用 sendHardwareDeviceMessage API 报错 -604100 API not found 请告知如何中云函数中如何正确使用sendHardwareDeviceMessage? Error: errCode: -604100 API not found | errMsg: system error: error code: -604100 at callGeneralOpenAPI (D:\workspace\WX\xbee\cloudfunctions\sent_notice\node_modules\wx-server-sdk\index.js:487:27) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async callWXOpenAPI (D:\workspace\WX\xbee\cloudfunctions\sent_notice\node_modules\wx-server-sdk\index.js:2364:28) at async d.exports.main [as handler] (D:\workspace\WX\xbee\cloudfunctions\sent_notice\index.js:211:22)
2023-07-03header: { "content-type": "application/json", "User-Agent": "Request-Promise" } 应该写为headers , 多一个S 就可以了
如何通过云函数访问移动OneNet?大家好!我在通过小程序访问外网数据时,遇到了问题,访问的网址是移动OneNet平台,我已经设置了request域名为 https://api.heclouds.com,情况如下: 1、在小程序端,直接使用wx.request访问,没有问题,代码如下: wx.request({ url: "https://api.heclouds.com/devices/"+ID+"/datapoints", header: { "api-key": "*********=" }, success (res) { console.log("Net:",res.data); } }) 2、当我将代码改为通过云函数访问时,采用的是request-promise模块,始终报错: {"errno":6,"error":"invalid parameter: auth by api-key or authorization"} 代码如下: var rp=require("request-promise"); var option={ url: "https://api.heclouds.com/devices/12345678/datapoints", method: "GET", json: true, qs: { "api-key": "******=" }, header: { "content-type": "application/json", "User-Agent": "Request-Promise" } }; await rp(option) .then(function (repos) { console.log('User has repos', repos.length); }) 3、我测试了request和requset-promise两种访问方式,都一样不行。 4、我测试了安装wx-server-sdk,再安装request和request-promise,不行。 5、我测试了只安装wx-server-sdk,并使用它自带的request版本,也不行。 6、移动的api-key 字符串里面有一个等号字符,传输时变成%3D,是不是这个字符的问题?但在小程序端又是可以的。 还望大家不吝赐教,谢谢!
2023-06-18