Custom Webhook Thingsboard

I install the on-premise community edition Thingboard, I think the integration with Particle will be easy but…
I configure a device in thingboards “Pluviometro”, and try to configure a custom webhook in Particle.
My event is rain, but I read the webhook guide in Particles Docs and are very confuse for me.I’m far away from json’s…:(( .
If somebody give me some help it will be awesome.

curl -v -X POST -d “{“Pluviometro”: 32}” http://things.hackuy.com:8080/api/v1/$TOKEN_THINGSBOARD/telemetry --header “Content-Type:application/json”

thanks in advance

Sorry didn’t see this post so is a duplicate to the one I created from your Private message.

Pablo, firstly your Quotes are wrong. Try using Double quotes for the curl parameter but single quotes in the JSON parameter.
Secondly, The TOKEN_THINGSBOARD should be the device token, so In thingsboard click on Manage Credentials and use the TB generate token. Then you should have a telemetry update.
E.G. curl -v -X POST -d "{'temperature': 25}" https://www.s2j.io:8080/api/v1/1a2b3c4d5e6f7g8h9i0j/telemetry --header "Content-Type:application/json"

Responding to a Private Message from Pablo Rattin

Hi Jhonny, I want to add a particle to thingsboards via webhook?
I read your post in the comunity, I’m total lost,I’m far far far away of json’s etc.

curl -v -X POST -d “{“temperature”: 25}” http://things.xxxxx.com/api/v1/$TOKEN_THINGSBOARD/telemetry --header “Content-Type:application/json”

I test the device over thingboard with curl.
Any help will be very appreciated

Pablo, firstly your Quotes are wrong. Try using Double quotes for the curl parameter but single quotes in the JSON parameter.
Secondly, The TOKEN_THINGSBOARD should be the device token, so In thingsboard click on Manage Credentials and use the TB generate token. Then you should have a telemetry update.
E.G. curl -v -X POST -d "{'temperature': 25}" https://www.s2j.io:8080/api/v1/1a2b3c4d5e6f7g8h9i0j/telemetry --header "Content-Type:application/json"

Thank you for your fast respones, definetl you put me in the way.
I read the documents in particle, and look for rickass tutorials,
Thank you for your advice, Irealy appreciate!!!
Friendly }regards from Uruguay
{
“event”: “rain”,
“url”: “http://things.hackuy.com:8080/api/v1"Put the Token here : ))”/telemetry",
“requestType”: “POST”,
“rejectUnauthorized”: false,
“headers”: {
“Content-Type”: “text/json”
},
“json”: {
“Pluviometro”: “{{PARTICLE_EVENT_VALUE}}”
},
“noDefaults”: true
}

Just in case someone stumbles across this, I have been trying to do the same, get data from a mesh device into thingsboard. It took a bit of fiddling to get the format right, but for me it turned out to be far simpler than I expected. It is a very cut down version of the above.

I produced the JSON in my code:

   // Publish as events
    sprintf(jsonOut, "{'battery': %0.2f;'soilMoisture': %d;'humidity': %0.2f; 'temperature': %0.2f; 'pressure': %0.2f}",
      batVolts, s, humid, temp, pres);
    Particle.publish("Soil1JSON", jsonOut, PRIVATE);

In thingsboard under device management, create your device and copy the token.

Create a webhook with the URL:
http://yourserver:yourPort/api/v1/AccessToken/telemetry
pasting in your server name, port and access token

Set the type to POST and format JSON. For the JSON just use:

"{{{PARTICLE_EVENT_VALUE}}}"

Thingsboard then just picks up on the field names in your JSON, so to add a new data stream, just add an extra section to your JSON.

1 Like

Hi Dave,
I am close but this hasn’t quite worked for me and I wonder if it’s because the data is being sent with a " before the {.

Here is the output of my webhook:

{
“name”: “osVoltage”,
“data”: “{‘temp’: 14.20, ‘voltage’: 3.64}”,
“ttl”: 60,
“published_at”: “2020-05-21T13:32:21.120Z”,
“coreid”: “e00fce68b0560d86910c7c4d”
}

All of this data comes into my things board however the field data is populated with the string {‘temp’: 14.20, ‘voltage’: 3.64} and not the JSON format where I would expect to have extra fields that I can use in my dashboard.

Were you able to work around that? Any ideas there?

Thanks.

Ok, I fixed by doing as you said, all you need in the JSON for the webhook is: “{{{PARTICLE_EVENT_VALUE}}}”

1 Like