# Webhooks & Parse.com

**URL:** <https://community.particle.io/t/webhooks-parse-com/13010>\
**Category:** Firmware\
**Created:** [July 5, 2015, 5:36pm UTC](https://community.particle.io/t/webhooks-parse-com/13010 "2015-07-05T17:36:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidgatti](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/davidgatti/32/9672_2.png) [@davidgatti](https://community.particle.io/u/davidgatti)\
**Post date:** [July 5, 2015, 5:36pm UTC](https://community.particle.io/t/webhooks-parse-com/13010/1 "2015-07-05T17:36:19Z")

</div>

Hello beautfiull Particle People 😄

I’m having a hard time making Webhooks work. After reading the documentation I have more questions then hawsers 🙂

I want to create a object in my Parse database [https://parse.com/docs/rest/guide#objects](https://parse.com/docs/rest/guide#objects). The code bellow is the .json file that i have created.

```
{
  "event": "parse",
  "url": "https://api.parse.com/1/classes/History",
  "requestType": "POST",
  "auth": {
    "X-Parse-Application-Id": "XXX",
    "X-Parse-REST-API-Key": "XXX"
  },
  "headers": {
    "Content-Type": "application/json"
    },
  "json": {
    "accessorieID":"{{accessorieID}}",
    "user":"{{user}}"
  },
  "mydevices": true
}

```

The code on for the Core is as follow:

```
#define publish_delay 10000
unsigned int lastPublish = 0;

void setup() {

}

void loop() {
    unsigned long now = millis();

    if ((now - lastPublish) < publish_delay) {
        // it hasn't been 10 seconds yet...
        return;
    }

    Spark.publish("parse", "{ \"accessorieID\": \"tAUJDAEUXK\", \"user\": \"3wEtpxS126\" }", 60, PRIVATE);

    lastPublish = now;
}

```

When I do “particle subscribe mine” i get no errors from Parse.

```
{"name":"parse","data":"{ \"accessorieID\": \"tAUJDAEUXK\", \"user\": \"3wEtpxS126\" }","ttl":"60","published_at":"2015-07-05T17:30:18.111Z","coreid":"54ff6a066678574919370667"}
{"name":"parse","data":"{ \"accessorieID\": \"tAUJDAEUXK\", \"user\": \"3wEtpxS126\" }","ttl":"60","published_at":"2015-07-05T17:30:28.110Z","coreid":"54ff6a066678574919370667"}
{"name":"parse","data":"{ \"accessorieID\": \"tAUJDAEUXK\", \"user\": \"3wEtpxS126\" }","ttl":"60","published_at":"2015-07-05T17:30:38.128Z","coreid":"54ff6a066678574919370667"}
{"name":"parse","data":"{ \"accessorieID\": \"tAUJDAEUXK\", \"user\": \"3wEtpxS126\" }","ttl":"60","published_at":"2015-07-05T17:30:48.110Z","coreid":"54ff6a066678574919370667"}
{"name":"parse","data":"{ \"accessorieID\": \"tAUJDAEUXK\", \"user\": \"3wEtpxS126\" }","ttl":"60","published_at":"2015-07-05T17:30:58.114Z","coreid":"54ff6a066678574919370667"}
{"name":"parse","data":"{ \"accessorieID\": \"tAUJDAEUXK\", \"user\": \"3wEtpxS126\" }","ttl":"60","published_at":"2015-07-05T17:31:08.117Z","coreid":"54ff6a066678574919370667"}
{"name":"parse","data":"{ \"accessorieID\": \"tAUJDAEUXK\", \"user\": \"3wEtpxS126\" }","ttl":"60","published_at":"2015-07-05T17:31:18.112Z","coreid":"54ff6a066678574919370667"}

```

But nothing is being created in the Parse database. I tried a bunch of things but nothing seams to work.

I would be grateful is someone could check the code above and see what might be wrong.

Best.

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [July 5, 2015, 7:56pm UTC](https://community.particle.io/t/webhooks-parse-com/13010/2 "2015-07-05T19:56:32Z")

</div>

@davidgatti, I don’t see anything obvious except for the missing spaces after your “:” in the json section. 😉

---

<div class="post-metadata">

**Author:** ![davidgatti](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/davidgatti/32/9672_2.png) [@davidgatti](https://community.particle.io/u/davidgatti)\
**Post date:** [July 5, 2015, 8:22pm UTC](https://community.particle.io/t/webhooks-parse-com/13010/3 "2015-07-05T20:22:02Z")

</div>

That seams not to be the issue. Are you able to explain to me how is the son structure is being used?

```
"json": {
    "accessorieID":"{{accessorieID}}",
    "user":"{{user}}"
  },

```

Because in the Core code i just have one variable, a blob of data. Because i managed to work but not quite. I finally are able to make new rows, but there is no data saved in the columns. And right now my .json looks like this:

```
"json": {
    "test": "{{the-state}}"
  },

```

How is are the tags being used?

---

<div class="post-metadata">

**Author:** ![1chef](https://avatars.discourse-cdn.com/v4/letter/1/ba9def/32.png) [@1chef](https://community.particle.io/u/1chef)\
**Post date:** [July 5, 2015, 11:43pm UTC](https://community.particle.io/t/webhooks-parse-com/13010/4 "2015-07-05T23:43:40Z")

</div>

I think problem might be in authentication data format.  
Read [parse docs](https://www.parse.com/docs/rest/guide#objects-creating-objects "Parse REST API — Creating Objects") for more info, try to do requests with `curl`  
And try to use this hook:

```
{
  "event": "parse",
  "url": "https://api.parse.com/1/classes/History",
  "requestType": "POST",
  "headers": {
    "X-Parse-Application-Id": "XXX",
    "X-Parse-REST-API-Key": "XXX",
    "Content-Type": "application/json"
    },
  "json": {
    "accessorieID":"{{accessorieID}}",
    "user":"{{user}}"
  },
  "mydevices": true
}

```

---

<div class="post-metadata">

**Author:** ![davidgatti](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/davidgatti/32/9672_2.png) [@davidgatti](https://community.particle.io/u/davidgatti)\
**Post date:** [July 5, 2015, 11:55pm UTC](https://community.particle.io/t/webhooks-parse-com/13010/5 "2015-07-05T23:55:27Z")

</div>

Sadly that is not the issue. I used Postman to make REST queries to Parse, and everything works fine. I found some bugs in the JSON itself, but fixed them and making direct REST request works.

I managed also to create rows in to Parse from Particle but without any data attached. I tried to write a name for a String type column. And I got a new row but the name was empty.

The .json looks like this now:

```
{
  "event": "parse",
  "url": "https://api.parse.com/1/classes/History",
  "requestType": "POST",
  "headers": {
    "X-Parse-Application-Id": "XXX",
    "X-Parse-REST-API-Key": "XXX",
    "Content-Type": "application/json"
  },
  "json": {
    "user" : {
      "__type" : "{{a}}",
      "className" : "{{a-a}}",
      "objectId" : "{{a-b}}"
    },
    "accessorieID" : {
      "__type" : "{{b}}",
      "className" : "{{b-a}}",
      "objectId" : "{{b-b}}"
    }
  },
  "mydevices": true
}

```

Firmware with the JSON is this:

```
Spark.publish("parse", "{ \"user\" : { \" __type\" : \"Pointer\", \"className\" : \"_User\", \"objectId\" : \"3wEtpxS126\" }, \"accessorieID\" : { \"__ type\" : \"Pointer\", \"className\" : \"Accessories\", \"objectId\" : \"tAUJDAEUXK\" }}", 60, PRIVATE);

```

I spent two days on this and I have no idea what to do else. To me it seams that I don’t understand the .json and I’m doing something wrong there.

**FACTS**

- Doing direct REST calls works, which means there is no issue on Parse side
- Authentication works, because if I try to save a string value I can create a empty row with no data.
- If I put wrong credentials I get an error message from Parse, so the authentication process is correct.

I have no idea what to do more.

---

<div class="post-metadata">

**Author:** ![1chef](https://avatars.discourse-cdn.com/v4/letter/1/ba9def/32.png) [@1chef](https://community.particle.io/u/1chef)\
**Post date:** [July 6, 2015, 12:23am UTC](https://community.particle.io/t/webhooks-parse-com/13010/6 "2015-07-06T00:23:53Z")

</div>

As I understand, particle makes simple substitution replacing `{{key}}` in you hook with `"key":"value"` from your `Spark.publish`. You should have simple dictionary without any hierarchy.  
So you should rewrite it like this:

```
Spark.publish("parse", "{ \"a\" : \"Pointer\", \"a-a\" : \"_User\", \"a-b\" : \"3wEtpxS126\", \"b\" : \"Pointer\", \"b-a\" : \"Accessories\", \"b-b\" : \"tAUJDAEUXK\" }", 60, PRIVATE);

```

And use better names 😊.  
Also try to avoid dashes (`'-'`) in names, prefer CamelCase or underscores.  
Also remember that data field in `Spark.publish` is [limited to 255 symbols](http://docs.particle.io/photon/firmware/#spark-publish).

---

<div class="post-metadata">

**Author:** ![1chef](https://avatars.discourse-cdn.com/v4/letter/1/ba9def/32.png) [@1chef](https://community.particle.io/u/1chef)\
**Post date:** [July 6, 2015, 12:35am UTC](https://community.particle.io/t/webhooks-parse-com/13010/7 "2015-07-06T00:35:03Z")

</div>

Check `Core/Logs/Error` and `Core/Logs/Info` on [Parse.com](http://Parse.com)

---

<div class="post-metadata">

**Author:** ![davidgatti](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/davidgatti/32/9672_2.png) [@davidgatti](https://community.particle.io/u/davidgatti)\
**Post date:** [July 6, 2015, 12:55am UTC](https://community.particle.io/t/webhooks-parse-com/13010/8 "2015-07-06T00:55:03Z")

</div>

Sadly your solution doesn’t work. Same problem. I the request goes, no error but also no confirmation that the new object was created.

- dashes are good as any char as far as i know
- underscore is something that Pare enforces with on their own tables.

_Core/Logs/Erro_r and _Core/Logs/Info_ are only for when you have a node app hosted on their servers

---

<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:** [July 6, 2015, 1:09am UTC](https://community.particle.io/t/webhooks-parse-com/13010/9 "2015-07-06T01:09:00Z")

</div>

Hi @davidgatti

Since you have your host working with Postman, I would use [http://requestb.in](http://requestb.in) to debug what you are sending with the Webhook versus what you are sending with Postman. Usually it is pretty obvious what is wrong.

---

<div class="post-metadata">

**Author:** ![davidgatti](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/davidgatti/32/9672_2.png) [@davidgatti](https://community.particle.io/u/davidgatti)\
**Post date:** [July 6, 2015, 1:17am UTC](https://community.particle.io/t/webhooks-parse-com/13010/10 "2015-07-06T01:17:24Z")

</div>

@bko not sure how that is different from Postman, but thee you go: [http://requestb.in/ypjcc3yp?inspect](http://requestb.in/ypjcc3yp?inspect).

I can create entries to Parse with Postman or strait CURL. The issue is that there is something wrong on the Particle side. My code or Particle code. Right now I what I do with straight CURL works, when I convert what works to Parse it stops working.

---

<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:** [July 6, 2015, 2:22am UTC](https://community.particle.io/t/webhooks-parse-com/13010/11 "2015-07-06T02:22:30Z")

</div>

Hi @davidgatti

What I meant was to change the web hook to post to requestb.in so that you can see what you web hook is sending.

Is that what is in your bin? It looked like a postman request instead of a web hook request.

---

<div class="post-metadata">

**Author:** ![davidgatti](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/davidgatti/32/9672_2.png) [@davidgatti](https://community.particle.io/u/davidgatti)\
**Post date:** [July 6, 2015, 2:30am UTC](https://community.particle.io/t/webhooks-parse-com/13010/12 "2015-07-06T02:30:28Z")

</div>

@bko Ooo… that how you use that 🙂 genius. OK, so the issue seams now really clear, this is Particle is sending out:

```
{"event":"parse","data":"{ \"a\" : \"Pointer\", \"a-a\" : \"_User\", \"a-b\" : \"3wEtpxS126\", \"b\" : \"Pointer\", \"b-a\" : \"Accessories\", \"b-b\" : \"tAUJDAEUXK\" }","published_at":"2015-07-06T02:25:55.823Z","coreid":"54ff6a066678574919370667","user":{" __type":"Pointer","className":"_User","objectId":"3wEtpxS126"},"accessorieID":{"__ type":"Pointer","className":"Accessories","objectId":"tAUJDAEUXK"}} 

```

For some reason it appends the JSON from the firmware. While later actually structuring everything the right way. I’m looking at my code and the tutorial and can’t see anything wrong.

Any ideas?

---

<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:** [July 6, 2015, 3:01am UTC](https://community.particle.io/t/webhooks-parse-com/13010/13 "2015-07-06T03:01:06Z")

</div>

Hi @davidgatti

Maybe @peekay123 or @Dave can help more.

The only thing I can imagine is that there is some magic that happens when you include a application-json header

---

<div class="post-metadata">

**Author:** ![davidgatti](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/davidgatti/32/9672_2.png) [@davidgatti](https://community.particle.io/u/davidgatti)\
**Post date:** [July 6, 2015, 3:32am UTC](https://community.particle.io/t/webhooks-parse-com/13010/14 "2015-07-06T03:32:36Z")

</div>

@bko removing “Content-Type”: “application/json” hase not effect ☹

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [July 6, 2015, 12:03pm UTC](https://community.particle.io/t/webhooks-parse-com/13010/15 "2015-07-06T12:03:03Z")

</div>

@davidgatti, I had an issue with the “added” payload when I was posting a GET request on breezometer. The assumption was that the receiving server would ignore the added payload but that is not always the case. Perhaps @Dave can shed some light on this.

---

<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:** [July 7, 2015, 2:22am UTC](https://community.particle.io/t/webhooks-parse-com/13010/16 "2015-07-07T02:22:14Z")

</div>

Hi @davidgatti,

I think the default behavior is to include everything, under the assumption that extra data will get ignored by the target website. It sounds like this isn’t the case here. I’d love to make sure webhooks can send the kinds of requests you need. Is the issue here more that the wrong headers are being sent (app/json?), or that extra properties are being included (defaults from the published event)?

edit: If you want it to just not set the “application/json” header, use the “form” property instead of the “json” property when creating up the webhook.

Thanks!  
David

---

<div class="post-metadata">

**Author:** ![davidgatti](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/davidgatti/32/9672_2.png) [@davidgatti](https://community.particle.io/u/davidgatti)\
**Post date:** [July 7, 2015, 3:22am UTC](https://community.particle.io/t/webhooks-parse-com/13010/17 "2015-07-07T03:22:53Z")

</div>

Sadly Parse doesn’t have the track record to do everything the right way. And who knows if this is one of those things. I think it would be great if sending everything could be an opt in options.

But i general: what is the benefit of sending everything?

About the form: I will try it, but I have few questions:

- authentication: do i keep the credentials (Application ID and Token) in the header?
- JSON: do i keep the structure the same as i have it now?

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [July 7, 2015, 12:26pm UTC](https://community.particle.io/t/webhooks-parse-com/13010/18 "2015-07-07T12:26:07Z")

</div>

@Dave, could a flag in the webhook definition be added to indicate whether the webhook should send the extra data or not?

---

<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:** [July 7, 2015, 2:53pm UTC](https://community.particle.io/t/webhooks-parse-com/13010/19 "2015-07-07T14:53:45Z")

</div>

Hi @peekay123,

Totally! I think that makes sense, just trying to get a feel for how to present that, how it should work, etc. 🙂

Thanks!  
David

---

<div class="post-metadata">

**Author:** ![davidgatti](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/davidgatti/32/9672_2.png) [@davidgatti](https://community.particle.io/u/davidgatti)\
**Post date:** [July 7, 2015, 3:37pm UTC](https://community.particle.io/t/webhooks-parse-com/13010/20 "2015-07-07T15:37:25Z")

</div>

@Dave please do 🙂 I wooden mind for example:

- raw: true/false

ps. could you answer my 2 last questions? 🙂

[Next page](https://community.particle.io/t/webhooks-parse-com/13010.md?page=2)
