I have the followiing payload with fields of arrays:
{"timestamp":1686127509414,
"topic":"NodeID;ns=3;s=\"V20Reg\".\"Pos\"",
"payload":[{"measurement":"V20RegPos",
"fields":[
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":8,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":419,"stVisu":2,"batchNbr":3,"key":129,"stPlate":0,"note":0},
{"rcpNbr":419,"stVisu":2,"batchNbr":3,"key":129,"stPlate":0,"note":0},
{"rcpNbr":419,"stVisu":2,"batchNbr":3,"key":129,"stPlate":0,"note":0},
{"rcpNbr":419,"stVisu":6,"batchNbr":3,"key":128,"stPlate":0,"note":0},
{"rcpNbr":419,"stVisu":6,"batchNbr":3,"key":127,"stPlate":0,"note":0},
{"rcpNbr":419,"stVisu":6,"batchNbr":3,"key":127,"stPlate":0,"note":0},
.
.
.
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0},
{"rcpNbr":0,"stVisu":0,"batchNbr":0,"key":0,"stPlate":0,"note":0}],
"timestamp":1686127509414000000}],
"_msgid":"517dfd98f7dc934c",
"measurement":"V20RegPos",
"statusCode":{"value":0},
"serverTimestamp":"2023-06-07T08:45:09.378Z",
"sourceTimestamp":"2023-06-07T08:45:09.378Z"}
When I try to parse the above payload through the InfluxDB Batch node, I get the following error from influxDB batch node:
Error: A 400 Bad Request error occurred:
{"error":"unable to parse 'V20RegPos
0=[object Object],1=[object Object],
10=[object Object],100=[object Object],
101=[object Object],102=[object Object],
103=[object Object],104=[object Object],
105=[object Object],106=[object Object],
107=[object Object],108=[object Object],
109=[object Object],11=[object Object],
110=[object Object],111=[object Object],
112=[object Object],113=[object Object],
114=[object Object],115=[object Object],
116=[object Object],117=[object Object],
118=[object Object],119=[object Object],
12=[object Object],120=[object Object],
121=[object Object],122=[object Object],
123=[object Object],124=[object Object],
125=[object Object],126=[object Object],
127=[object Object],128=[object Object],
129=[object Object],13=[object Object],
130=[object Object],131=[object Object],
132=[object Object],133=[object Object],
.
.
.
89=[object Object],9=[object Object],
90=[object Object],91=[object Object],
92=[object Object],93=[object Object],
94=[object Object],95=[object Object],
96=[object Object],97=[object Object],
98=[object Object],99=[object Object]
1686129685511000000': invalid boolean"}
My Data formating Function:
var timestamp = msg.timestamp*1e6; //new Date().getTime() *1e6;
if (typeof msg.payload === "object"){ //if measurement/payload is a struct/object
msg.payload = [
{
measurement: msg.measurement,
fields: msg.payload,
timestamp: timestamp
}
]
}
else{ // if the measurement/payload is singler var
msg.payload = [
{
measurement: msg.measurement,
fields: {value: msg.payload},
timestamp: timestamp
}
]
}
return msg;
My NodeRed Flow:
Any Idea, what am I doing wrong here?