Hello. Could you please help me with the issue of filling a table with data using a webhook of a third-party service imonnit.com?
imonnit is a service for monitoring sensors and collecting data from them, with each sensor event, the imonnit service sends data in the form of JSON via a web hook to a url in the form of a post request.
Here is an example of a request sent by a webhook:
{
"gatewayMessage":{
"gatewayID":"10000" ,
"gatewayName":"ExampleGateway" ,
"accountID":"xxxx" ,
"networkID":"xxxx" ,
"messageType":"0" ,
"power":"0",
"batteryLevel": "101" ,
"date": 2022-4-28 21:47:01",
"count":"3",
"signalStrength": "29",
"pendingChange": "False"
},
"sensorMessages":[
{
"sensorID":"10001" ,
"sensorName":"Temp1" ,
"applicationID":"2" ,
"networkID":"xxxx" ,
"dataMessageGUID":"78642056-CBD8-43B0-9A4B-247E58D3B6CB",
"state": "0" ,
"messageDate": 2022-4-28 21:48:01",
"rawData":"23.7",
"dataType": "TemperatureData",
"dataValue": "23.7",
"plotValues": "74.66",
"plotLabels": "Fahrenheit",
"batteryLevel": "100",
"signalStrength": "100",
"pendingChange": "False",
"voltage": "3.24"
}
],
"locationMessages":[
{
"deviceID":"10000" ,
"locationMessageGUID":"5badfa3d-f110-4058-81cd-1ade90983adb",
"locationDate":"2022-4-28 21:47:11",
"state":"0",
"latitude":"40.6977500915527",
"longitude": "-111.894149780273",
"altitude": "1302",
"speed":"0",
"course": "0",
"fixTime": "24",
"sateliteCount": "6",
"uncertainty": "1"
}
]
}
I have a table: “messages” for which there is an api in the system through which I can fill it with /data/bulk/messages, but the problem is that the webhook sends me an object with unnecessary data and I only need the structure of the sensorMessages array from the data of this webhook.
Is there any way to add some additional handler that will get the sensorMessages array from the object and then use the /data/bulk/messages url to fill the table? If you need more details, I will write.
Please advise something, I will be very grateful.