Receive data using a webhook

Hi there,
My device can send data to Losant via a HTTPS POST and I have set up a webhook for this.
Unfortunately I’m not receiving the data in Losant and looking at the url POST from the device, here is what I see:

Wed Jan 13 11:21:26 2021 daemon.info iojuggler: executing action id=1
Wed Jan 13 11:21:26 2021 daemon.info iojuggler: POST: https://triggers.losant.com/webhooks/XXXXXXXXXXXXX?input3=falling&time=2021-01-13%2011%3A21%3A26&seralnumber=XXXXXX&inputname=dio0

My understanding is that the device adds a query string to the url to send the parameters. Can I receive this in Losant?
Cheers
Jules

Further to my question above, I have two ways to send my data to Losant from my device.

1 - I can send the data based on time interval, which is not ideal for my application. I am receiving the data in Losant by using a webhook. Here is the payload result:
image
Note that I should have a JSON object in the body response, but that’s a secondary problem.

2 - I can send the data based on change of input status, which is the solution I have described in my initial post. I tested the solution with https://webhook.site/ and here is what I get:

I’m not receiving anything in Losant using this solution, any idea what could be the issue?

Hi @Jules_Huguenin,

1 - I can send the data based on time interval, which is not ideal for my application. I am receiving the data in Losant by using a webhook. Here is the payload result:

I did some testing on my end and was able to reproduce the behavior you are seeing in the first image. When posting data to a Losant Webhook where the body of the request is a JSON object, the content-type should be application/json. When using content-type of application/x-www-form-urlencoded I experienced the same behavior you did:

When I sent the query parameters you mentioned in your first question I was able to successfully see the data in a payload in Losant, but in the query section, rather than the body section:

image

Let me know if changing the content-type to application/json works for you!

I’m not receiving anything in Losant using this solution, any idea what could be the issue?

When you say “I’m not receiving anything in Losant using this solution…” do you mean that a workflow is not being triggered? Or do you mean that the workflow is being triggered, but the data that you are including as query parameters is not on the payload?

Thank you,
Heath

1 Like

Hi @Heath,
Thanks for your answer, I have found the problem and it’s on the device side. There is too many characters for the webhook URL input field and I wasn’t given an alert when pasting the URL into the field.
It must be a bug with the device’s firmware and I have raised the question with support.

I will try to change the content type once the URL input field problem is fixed.
Cheers
Jules

[update]

I have used the experience endpoint as a workaround for my problem with the length of the webhook URL (thanks to Webhook too long for server).

The data is coming in nicely in data instead of query, without changing the content-type:
image

Do I need to create an Endpoint reply node in my workflow? With or without it I get this response:
{ "error": "No endpoint found for this route" }

Cheers
Jules

I had the same issue with long webhooks.
I switch to a endpoint with “No Static Reply (use experience workflow to reply)”
Mine responds with a message id and Time/Date.