# Webhook responses

**URL:** <https://community.particle.io/t/webhook-responses/58523>\
**Category:** Cloud\
**Created:** [November 21, 2020, 9:15pm UTC](https://community.particle.io/t/webhook-responses/58523 "2020-11-21T21:15:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveH](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@DaveH](https://community.particle.io/u/DaveH)\
**Post date:** [November 21, 2020, 9:15pm UTC](https://community.particle.io/t/webhook-responses/58523/1 "2020-11-21T21:15:35Z")

</div>

I’ve got a couple of questions about webhooks I’ve been struggling to find the answer for.

The first, is that if the data is split up into more than one response, how do you know when it is finished and you have all the data? Is it best to check the size of the response or just see if ‘}’ is the last character?

The second is about testing via a CLI while I’m getting the template and other options correct. If I use:

```auto
curl "https://api.particle.io/v1/integrations/.....

```

Rather than just the output, I get over 24k of data back, with the JSON I requested repeated many times. Is there a way to trigger a webhook and just see a single response?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 22, 2020, 7:59am UTC](https://community.particle.io/t/webhook-responses/58523/2 "2020-11-22T07:59:36Z")

</div>

> [@DaveH](#):
>
> Is there a way to trigger a webhook and just see a single response?

You could use `particle subscribe` to catch only the webhook-responses just like you would do on the device.

---

<div class="post-metadata">

**Author:** ![DaveH](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@DaveH](https://community.particle.io/u/DaveH)\
**Post date:** [November 22, 2020, 10:02am UTC](https://community.particle.io/t/webhook-responses/58523/3 "2020-11-22T10:02:19Z")

</div>

Thanks, that is what I currently have:

```auto
Particle.subscribe("hook-response/thingsboard-in-keysensors", webhookHandler);
......
void webhookHandler(const char *event, const char *data) {
  Serial.println("Webhook triggered");
  Serial.println(event);
  Serial.println("Data=");
  Serial.println(data);
}

```

I’m busy trying to learn about the webhook filterings to reduce the amount of data sent, but currently the returned JSON returns two responses. If I’m going to parse the JSON, I need to stick the two bits together first. Is there any data that is sent in the webhook responses that says this is the last chunk?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 22, 2020, 10:49am UTC](https://community.particle.io/t/webhook-responses/58523/4 "2020-11-22T10:49:02Z")

</div>

> [@DaveH](#):
>
> Is there any data that is sent in the webhook responses that says this is the last chunk?

Not that I know of, since the cloud also doesn't know how long the remote server will keep sending responses back and when it's done sending.  
Typically your code should know what it requested and how to determine when all the expected data has been received completely (e.g. the JSON root object gets closed).

After all the Particle cloud is only the "delivery man" and has no knowledge about the data in itself - usually the sender and recipient have.

---

<div class="post-metadata">

**Author:** ![DaveH](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@DaveH](https://community.particle.io/u/DaveH)\
**Post date:** [November 22, 2020, 2:28pm UTC](https://community.particle.io/t/webhook-responses/58523/5 "2020-11-22T14:28:33Z")

</div>

Thanks, that makes sense. It look like 512 is a max chunk size, so I’ve got two ways of dealing with it. One is to assume that if the returned data is 512 and does not end in ‘}’, then there is probably more to come. Or just keep a count of { and }, then assume when they match the data is done.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 22, 2020, 2:35pm UTC](https://community.particle.io/t/webhook-responses/58523/6 "2020-11-22T14:35:14Z")

</div>

You can also expect the full response to be delivered within a finite amount of time.  
When you are not getting a new partial response within some short period after the last I’d assume it’s save to conclude you already got it all.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/3/2/3291e3c9351789fe8620ae5bcec8d3fec67ff221.png) [@system](https://community.particle.io/u/system)\
**Post date:** [May 24, 2021, 2:35am UTC](https://community.particle.io/t/webhook-responses/58523/7 "2021-05-24T02:35:20Z")

</div>

Closed on May 24, 2021, 2:35am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
