Dear Particle-Community!
I am having trouble customizing the webhooks to work with a FI-Ware Contextbroker (see: context Broker Programmer Guide ). My Contextbroker expects the following json body in a POST request:
{
"contextElements":
[
{
"type":"Producer",
"isPattern":"false",
"id":"1234",
"attributes":
[
{
"name":"currentProduction",
"type":"float",
"value":"4321"
},
{
"name":"timestamp",
"type":"int",
"value":"123456789"
}
]
}
],
"updateAction":"UPDATE"
}
somehow the webhook adds the following fields:
{
"event": "{{SPARK_EVENT_NAME}}",
"data": "{{SPARK_EVENT_VALUE}}",
"published_at": "{{SPARK_PUBLISHED_AT}}",
"coreid": "{{SPARK_CORE_ID}}"
}
to every call. Thus the messages I am sending look like this (I have defined a custom variable "CURRENT_PRODUCTION) :
{
"event":"ProductionReport",
"data":"{ \"CURRENT_PRODUCTION\": \"0\" }",
"published_at":"123456789",
"coreid":"123456789abcddefghi",
"contextElements":
[
{
"type":"Producer",
"isPattern":"false",
"id":"1234",
"attributes": [
{
"name":"currentProduction",
"type":"float",
"value":"4321"
},
{
"name":"timestamp",
"type":"int",
"value":"123456789"
}
]
}
],
"updateAction":"UPDATE"
}
The values change in a correct manner - that’s all fine. I just want to get rid of the first four variables (event, data, published_at, coreid), which are added by the webhook. How could I achieve this?
To give it a quick fix I am calling a PHP function on my web server, which “translates” the data into a correct HTTP POST Request to the Context Broker. As this will create a lot of load on my server, as soon as the amount of devices scales up, I’d like to establish a direct connection.
Any help would be appreciated!
Thanks!
Tobi
I’ve edited your post to properly format the code. Please check out this post, so you know how to do this yourself in the future. Thanks in advance! ~Jordy