While Passing Array to Node and Reformating Array into an Object Data Gets Lost

I am extracting data from a CSV file, that I want to send to a server through an API Call. In order to limit the number of calls I'm formatting the request body to contain several data points at once. All this is working fine, besides the fact that only a fraction of the data is arriving at the server. I have debugged the problem and noticed that from one node to the next lies the problem.

I pass an array full of data points to a node and add this array to the body object for the API request. I pass this object on to the request node. When consoling the object only 1000 of the data points appear although a couple thousand were sent into the node. These were also received, but within the object not passed on.

All this is happening within the "Request Body Formatting" node.

I'd really appreciate any help! :slight_smile:

I've added the flow below:

[{"id":"947cab1a.0d5bf","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"65c95823.a10ae","type":"http request","z":"947cab1a.0d5bf","name":"","method":"POST","ret":"obj","paytoqs":true,"url":"http://192.168.183.2:8800/ppm/v2/measurement/","tls":"","proxy":"","authType":"basic","x":530,"y":300,"wires":[["f98141a.60f2a4"]]},{"id":"f98141a.60f2a4","type":"debug","z":"947cab1a.0d5bf","name":"","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","x":710,"y":300,"wires":[]},{"id":"b6e0592a.23c17","type":"inject","z":"947cab1a.0d5bf","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":120,"wires":[["55e126aa.826ec"]]},{"id":"ba311656.326d98","type":"csv","z":"947cab1a.0d5bf","name":"","sep":",","hdrin":true,"hdrout":"","multi":"one","ret":"\n","temp":"","skip":"0","x":870,"y":120,"wires":[["82139ff5.5695f"]]},{"id":"9b1fe86b.85791","type":"file in","z":"947cab1a.0d5bf","name":"","filename":"C:\Users\ABN1LR\Desktop\weldingDataFilter.csv","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":590,"y":120,"wires":[["ba311656.326d98"]]},{"id":"82139ff5.5695f","type":"function","z":"947cab1a.0d5bf","name":"Topic Added","func":"msg.topic = msg.payload.timerName;\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":200,"wires":[["c5e4f18c.4084e8"]]},{"id":"f9b9e089.404b3","type":"function","z":"947cab1a.0d5bf","name":"Data Processing","func":"full_batch = msg.payload;\nspatter_running_total = 0;\n\nvar spatter_rate_history = flow.get('spatter_rate_history') || {};\nvar spatter_running_total = flow.get('spatter_rate_running_total') || {};\nvar spatter_count = flow.get('spatter_count') || {};\n\nvar body_array = \n\nfor (var message_id in full_batch){\n \n if((full_batch[message_id]["stabilisationFactorActValue"] !== 0) ){\n\n timerName = full_batch[message_id]["timerName"];\n time = full_batch[message_id].dateTime;\n time_split = time.split("/");\n time_split_time = time_split[2].split(" ");\n time_split_hour_minute = time_split_time[1].split(":");\n time_split_hour = "0"+ time_split_hour_minute[0];\n hour = time_split_hour.substring(time_split_hour.length-2, time_split_hour.length+1);\n time_split_minute = "0"+ time_split_hour_minute[1];\n minute = time_split_minute.substring(time_split_minute.length-2, time_split_minute.length+1);\n var month = "03" //"0"+ time_split[0];\n month = month.substring(month.length-2, month.length+1);\n var day = "0"+ (parseInt(time_split[1])-15);\n day = day.substring(day.length-2, day.length+1);\n var year = "2019" //"20" + time_split_time[0];\n \n time_formatted = year + "-" + month + "-" + day + "T" + hour + ":" + minute + ":00Z";\n \n if (timerName in spatter_running_total){\n if (full_batch[message_id]["uirExpulsionTime"] !== 0){\n spatter_running_total[timerName] +=1;\n }\n }\n else{\n if (full_batch[message_id]["uirExpulsionTime"] !== 0){\n spatter_running_total[timerName] =1;\n }\n spatter_running_total[timerName] = 0;\n }\n \n if (timerName in spatter_count){\n spatter_count[timerName] +=1;\n }\n else{\n spatter_count[timerName] = 1;\n }\n \n body_array.push(\n {\n "ts": time_formatted,\n "result": "OK",\n "series": {\n "$_time": [\n 0\n ],\n "PSF": [\n full_batch[message_id].stabilisationFactorActValue\n ],\n "UIP":[\n full_batch[message_id].uipActualValue\n ],\n "Spatter Rate": [\n spatter_running_total[timerName]/spatter_count[timerName]\n ],\n "Voltage": [\n full_batch[message_id].voltageActualValue\n ],\n "Current":[\n full_batch[message_id].currentActualValue\n ],\n "uirExpulsionTime":[\n full_batch[message_id].uirExpulsionTime\n ]\n }\n }\n \n );\n \n if (timerName in spatter_rate_history){\n spatter_rate_history[timerName].push(spatter_running_total[timerName]/spatter_count[timerName]);\n }\n else{\n spatter_rate_history[timerName] = \n spatter_rate_history[timerName].push(spatter_running_total[timerName]/spatter_count[timerName]);\n }\n }\n \n}\n\nflow.set('spatter_rate_running_total', spatter_running_total);\nflow.set('spatter_count',spatter_count);\nflow.set('spatter_rate_history', spatter_rate_history);\n\nmsg.payload = body_array;\n\nreturn msg;\n\n\n","outputs":1,"noerr":0,"x":720,"y":200,"wires":[["911a10da.a93a58"]]},{"id":"911a10da.a93a58","type":"function","z":"947cab1a.0d5bf","name":"Request Body Formatting","func":"// MSG.PAYLOAD HOLDS THE DATA POINT ARRAY\n// when consoling the whole msg.payload from this node there is always a limit of 1000 data points\ncounter_test = msg.payload.length;\n \n msg.payload = {\n "content-spec": "urn:spec://eclipse.org/unide/measurement-message#v2",\n "device": {\n "deviceID": msg.topic\n },\n "measurements": msg.payload\n} ;\n\nmsg.headers = {'content-type':'application/json'};\nmsg.counter = counter_test;\nreturn msg;\n\n\n","outputs":1,"noerr":0,"x":270,"y":300,"wires":[["8be76cd5.757438"]]},{"id":"55e126aa.826ec","type":"function","z":"947cab1a.0d5bf","name":"Reset flow variables","func":"var spatter_rate_history = flow.get('spatter_rate_history') || {};\nvar spatter_running_total = flow.get('spatter_rate_running_total') || {};\nvar spatter_count = flow.get('spatter_count') || {};\n\nflow.set('spatter_rate_running_total', {});\nflow.set('spatter_count', {});\nflow.set('spatter_rate_history', {});\n\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":120,"wires":[["9b1fe86b.85791"]]},{"id":"c5e4f18c.4084e8","type":"batcher","z":"947cab1a.0d5bf","name":"","maxTopics":"5","maxMessagesPerTopic":"500000","maxDelay":"1000","x":473,"y":199.99998474121094,"wires":[["f9b9e089.404b3"]]},{"id":"8be76cd5.757438","type":"debug","z":"947cab1a.0d5bf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":467,"y":374.5999755859375,"wires":}]

Hi your code cannot be imported so I am not able to help.

Please put three back ticks above and below...

```
like this
```

The debug output only displays a portion (the real msg will have everything.

[
    {
        "id": "947cab1a.0d5bf",
        "type": "tab",
        "label": "Flow 5",
        "disabled": false,
        "info": ""
    },
    {
        "id": "65c95823.a10ae",
        "type": "http request",
        "z": "947cab1a.0d5bf",
        "name": "",
        "method": "POST",
        "ret": "obj",
        "paytoqs": true,
        "url": "http://192.168.183.2:8800/ppm/v2/measurement/",
        "tls": "",
        "proxy": "",
        "authType": "basic",
        "x": 530,
        "y": 300,
        "wires": [
            [
                "f98141a.60f2a4"
            ]
        ]
    },
    {
        "id": "f98141a.60f2a4",
        "type": "debug",
        "z": "947cab1a.0d5bf",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": true,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 710,
        "y": 300,
        "wires": []
    },
    {
        "id": "b6e0592a.23c17",
        "type": "inject",
        "z": "947cab1a.0d5bf",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 100,
        "y": 120,
        "wires": [
            [
                "55e126aa.826ec"
            ]
        ]
    },
    {
        "id": "ba311656.326d98",
        "type": "csv",
        "z": "947cab1a.0d5bf",
        "name": "",
        "sep": ",",
        "hdrin": true,
        "hdrout": "",
        "multi": "one",
        "ret": "\\n",
        "temp": "",
        "skip": "0",
        "x": 870,
        "y": 120,
        "wires": [
            [
                "82139ff5.5695f"
            ]
        ]
    },
    {
        "id": "9b1fe86b.85791",
        "type": "file in",
        "z": "947cab1a.0d5bf",
        "name": "",
        "filename": "C:\\Users\\ABN1LR\\Desktop\\weldingDataFilter.csv",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "x": 590,
        "y": 120,
        "wires": [
            [
                "ba311656.326d98"
            ]
        ]
    },
    {
        "id": "82139ff5.5695f",
        "type": "function",
        "z": "947cab1a.0d5bf",
        "name": "Topic Added",
        "func": "msg.topic = msg.payload.timerName;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 250,
        "y": 200,
        "wires": [
            [
                "c5e4f18c.4084e8"
            ]
        ]
    },
    {
        "id": "f9b9e089.404b3",
        "type": "function",
        "z": "947cab1a.0d5bf",
        "name": "Data Processing",
        "func": "full_batch = msg.payload;\nspatter_running_total = 0;\n\nvar spatter_rate_history = flow.get('spatter_rate_history') || {};\nvar spatter_running_total = flow.get('spatter_rate_running_total') || {};\nvar spatter_count = flow.get('spatter_count') || {};\n\nvar body_array = []\n\nfor (var message_id in full_batch){\n    \n    if((full_batch[message_id][\"stabilisationFactorActValue\"] !== 0) ){\n\n        timerName = full_batch[message_id][\"timerName\"];\n        time = full_batch[message_id].dateTime;\n        time_split = time.split(\"/\");\n        time_split_time = time_split[2].split(\" \");\n        time_split_hour_minute = time_split_time[1].split(\":\");\n        time_split_hour = \"0\"+ time_split_hour_minute[0];\n        hour = time_split_hour.substring(time_split_hour.length-2, time_split_hour.length+1);\n        time_split_minute = \"0\"+ time_split_hour_minute[1];\n        minute = time_split_minute.substring(time_split_minute.length-2, time_split_minute.length+1);\n        var month = \"03\" //\"0\"+ time_split[0];\n        month = month.substring(month.length-2, month.length+1);\n        var day = \"0\"+ (parseInt(time_split[1])-15);\n        day = day.substring(day.length-2, day.length+1);\n        var year = \"2019\" //\"20\" + time_split_time[0];\n        \n        time_formatted = year + \"-\" + month + \"-\" + day + \"T\" + hour + \":\" + minute + \":00Z\";\n        \n        if (timerName in spatter_running_total){\n            if (full_batch[message_id][\"uirExpulsionTime\"] !== 0){\n                spatter_running_total[timerName] +=1;\n            }\n        }\n        else{\n            if (full_batch[message_id][\"uirExpulsionTime\"] !== 0){\n                spatter_running_total[timerName] =1;\n            }\n            spatter_running_total[timerName] = 0;\n        }\n        \n        if (timerName in spatter_count){\n            spatter_count[timerName] +=1;\n        }\n        else{\n            spatter_count[timerName] = 1;\n        }\n        \n        body_array.push(\n            {\n              \"ts\": time_formatted,\n              \"result\": \"OK\",\n              \"series\": {\n                \"$_time\": [\n                  0\n                ],\n                \"PSF\": [\n                    full_batch[message_id].stabilisationFactorActValue\n                ],\n                \"UIP\":[\n                    full_batch[message_id].uipActualValue\n                    ],\n                \"Spatter Rate\": [\n                    spatter_running_total[timerName]/spatter_count[timerName]\n                    ],\n                \"Voltage\": [\n                    full_batch[message_id].voltageActualValue\n                    ],\n                \"Current\":[\n                    full_batch[message_id].currentActualValue\n                    ],\n                \"uirExpulsionTime\":[\n                    full_batch[message_id].uirExpulsionTime\n                    ]\n              }\n            }\n            \n        );\n        \n        if (timerName in spatter_rate_history){\n            spatter_rate_history[timerName].push(spatter_running_total[timerName]/spatter_count[timerName]);\n        }\n        else{\n            spatter_rate_history[timerName] = []\n            spatter_rate_history[timerName].push(spatter_running_total[timerName]/spatter_count[timerName]);\n        }\n    }\n    \n}\n\nflow.set('spatter_rate_running_total', spatter_running_total);\nflow.set('spatter_count',spatter_count);\nflow.set('spatter_rate_history', spatter_rate_history);\n\nmsg.payload = body_array;\n\nreturn msg;\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "x": 720,
        "y": 200,
        "wires": [
            [
                "911a10da.a93a58"
            ]
        ]
    },
    {
        "id": "911a10da.a93a58",
        "type": "function",
        "z": "947cab1a.0d5bf",
        "name": "Request Body Formatting",
        "func": "// MSG.PAYLOAD HOLDS THE DATA POINT ARRAY\n// when consoling the whole msg.payload from this node there is always a limit of 1000 data points\ncounter_test = msg.payload.length;\n \n msg.payload = {\n  \"content-spec\": \"urn:spec://eclipse.org/unide/measurement-message#v2\",\n  \"device\": {\n    \"deviceID\": msg.topic\n  },\n  \"measurements\": msg.payload\n} ;\n\nmsg.headers = {'content-type':'application/json'};\nmsg.counter = counter_test;\nreturn msg;\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "x": 270,
        "y": 300,
        "wires": [
            [
                "8be76cd5.757438"
            ]
        ]
    },
    {
        "id": "55e126aa.826ec",
        "type": "function",
        "z": "947cab1a.0d5bf",
        "name": "Reset flow variables",
        "func": "var spatter_rate_history = flow.get('spatter_rate_history') || {};\nvar spatter_running_total = flow.get('spatter_rate_running_total') || {};\nvar spatter_count = flow.get('spatter_count') || {};\n\nflow.set('spatter_rate_running_total', {});\nflow.set('spatter_count', {});\nflow.set('spatter_rate_history', {});\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 280,
        "y": 120,
        "wires": [
            [
                "9b1fe86b.85791"
            ]
        ]
    },
    {
        "id": "c5e4f18c.4084e8",
        "type": "batcher",
        "z": "947cab1a.0d5bf",
        "name": "",
        "maxTopics": "5",
        "maxMessagesPerTopic": "500000",
        "maxDelay": "1000",
        "x": 473,
        "y": 199.99998474121094,
        "wires": [
            [
                "f9b9e089.404b3"
            ]
        ]
    },
    {
        "id": "8be76cd5.757438",
        "type": "debug",
        "z": "947cab1a.0d5bf",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 467,
        "y": 374.5999755859375,
        "wires": []
    }
]

Are you checking the ouput using a debug node? If so, that is limited to about 1k characters by default.