# JSON Webhook Custom Template POST to Parse

**URL:** <https://community.particle.io/t/json-webhook-custom-template-post-to-parse/15311>\
**Category:** Troubleshooting\
**Created:** [September 9, 2015, 6:02pm UTC](https://community.particle.io/t/json-webhook-custom-template-post-to-parse/15311 "2015-09-09T18:02:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![m9er](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@m9er](https://community.particle.io/u/m9er)\
**Post date:** [September 9, 2015, 6:02pm UTC](https://community.particle.io/t/json-webhook-custom-template-post-to-parse/15311/1 "2015-09-09T18:02:08Z")

</div>

I know this is probably something simple I’m missing but I’ve been scouring the docs and forum for the last day to no avail.

My web hook:

```
 {
      "eventName": "post_data",
      "url": "https://api.parse.com/1/classes/SensorData",
      "requestType": "POST",
      "headers": {
          "X-Parse-Application-Id":"xxx",
          "X-Parse-REST-API-Key":"xxx",
          "Content-Type":"application/json"
      },
      "json": {
        "ph" : "{{ph}}",
        "temperature" : "{{temperature}}"
      },
      "mydevices": true
    }

```

And my firmware, customized from some of the readily available examples and tutorials. Using OneWire for my DS18b20, Wire for an Atlas Scientific pH circuit:

```
char ph_data[48]; // 48 byte char array to hold data from ph
float celsius, fahrenheit; // float to hold and convert data from temp

// Publish Data
  sprintf(resultStr, "%s %s", ph_data, String(fahrenheit).c_str());   

  Spark.publish("post_data", resultStr, 60, PRIVATE);
//Spark.publish("post_data", "{ \"ph\": \"ph_data\", \"temperature\": \"fahrenheit\" }", 60, PRIVATE);

```

With the above code, Parse creates the object and inputs blank data into the ph and temperature columns. Event Data on both Parse and Particle Dashboard shows current ph\_data and fahrenheit as a single string `(resultStr)`. Particle Dashboard shows hook-sent data as undefined.

If I switch to the commented out `Spark.publish` based on the Webhook Custom Template docs, Parse inputs plain text ph\_data and fahrenheit, not the values they represent.

Also, if I change

```
      "json": {
        "ph" : "{{ph}}",
        "temperature" : "{{temperature}}"
      },

```

to

```
      "json": {
        "ph" : "{{ph_data}}",
        "temperature" : "{{fahrenheit}}"
      },

```

it inputs blank data to Parse, regardless of which `Spark.publish` I use.

---

<div class="post-metadata">

**Author:** ![BulldogLowell](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bulldoglowell/32/4305_2.png) [@BulldogLowell](https://community.particle.io/u/BulldogLowell)\
**Post date:** [September 9, 2015, 6:15pm UTC](https://community.particle.io/t/json-webhook-custom-template-post-to-parse/15311/2 "2015-09-09T18:15:48Z")

</div>

> [@m9er](#):
>
> char ph\_data[48]; // 48 byte char array to hold data from ph  
> float celsius, fahrenheit; // float to hold and convert data from temp
> 
> // Publish Data  
> sprintf(resultStr, "%s %s", ph\_data, String(fahrenheit).c\_str());

can you show the event stream in a terminal using the CLI's `particle subscribe mine` once you publish "post\_data" ?

---

<div class="post-metadata">

**Author:** ![m9er](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@m9er](https://community.particle.io/u/m9er)\
**Post date:** [September 9, 2015, 6:26pm UTC](https://community.particle.io/t/json-webhook-custom-template-post-to-parse/15311/3 "2015-09-09T18:26:49Z")

</div>

Yes, it displays the same as the Particle Dashboard. Post, Hook-Sent, and Hook-Response. Hook data is undefined, Post data is “{ “ph”: “ph\_data”, “temperature”: fahrenheit }”

EDIT: To clarify, Post data is “3.355 79.137497” (ph and temp) if I use `Spark.publish("post_data", resultStr, 60, PRIVATE);` It’s “{ “ph”: “ph\_data”, “temperature”: fahrenheit }” if I use `Spark.publish("post_data", "{ \"ph\": \"ph_data\", \"temperature\": \"fahrenheit\" }", 60, PRIVATE);`

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [September 9, 2015, 6:35pm UTC](https://community.particle.io/t/json-webhook-custom-template-post-to-parse/15311/4 "2015-09-09T18:35:41Z")

</div>

> [@m9er](#):
>
> sprintf(resultStr, "%s %s", ph\_data, String(fahrenheit).c\_str());

Didn't you mean to say this instead?

```cpp
sprintf(resultStr, "{\"ph_data\": %s, \"temperature\": %s}", ph_data, String(fahrenheit).c_str());

```

---

<div class="post-metadata">

**Author:** ![m9er](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@m9er](https://community.particle.io/u/m9er)\
**Post date:** [September 9, 2015, 6:41pm UTC](https://community.particle.io/t/json-webhook-custom-template-post-to-parse/15311/5 "2015-09-09T18:41:18Z")

</div>

Just tried that and the event value comes up null instead of the combined strings.

Edit: Nevermind, it’s actually posting properly into Parse now even though the hook-sent data shows null in terminal. By the way it was your tutorials that got me going here so thanks for those as well as this fix!

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dave/32/181_2.png) [@Dave](https://community.particle.io/u/Dave)\
**Post date:** [September 9, 2015, 7:11pm UTC](https://community.particle.io/t/json-webhook-custom-template-post-to-parse/15311/6 "2015-09-09T19:11:44Z")

</div>

Hi @m9er,

Ahh sorry about that, the “hook-sent” event is to let you know that the hook was triggered and the request was started, the contents of that event are generally always null at the moment. 🙂

Thanks,  
David
