[SOLVED] Webhooks / Backand - Request doesn't get send

Hi,

I am having trouble using Webhooks with Backand. I created the following webhook:

{
    "event": "get_bell_object",
    "url": "{{BACKAND_API_URL}}/objects/bells",
    "requestType": "GET",
    "headers": {
        "AnonymousToken": "{{BACKAND_ANONYMOUS_TOKEN}}"
    },
    "query": {
        "filter": "[{\"fieldName\":\"{{device_type}}\",\"operator\":\"equals\",\"value\":\"{{device_id}}\"}]"
    },
    "mydevices": true,
    "noDefaults": true,
    "rejectUnauthorized": false
}

I subscribe and publish the event as follows:

Particle.subscribe("hook-response/get_bell_object", getBellObject, MY_DEVICES);

Particle.publish("get_bell_object", "{\"BACKAND_API_URL\":\"https://api.backand.com/1\", \"BACKAND_ANONYMOUS_TOKEN\":\"1234567890987654321\", \"device_type\":\"particle_bell_id\", \"device_id\":\"1234567890987654321\"}", 60, PRIVATE);

The problem is that the event handler never gets called. Using particle subscribe mine I do not see anything else than the event publishing. So I am not even sure the request is even sent. For sure there is no reply from Backend.

I tried to send the request to a requestb.in and it works. The query is well formatted and the event handler is called. I tried to call the Backand API with Postman and it also works.

Any clues?

Thanks,

Guillaume

Have you tried hardcoding the URL in your webhook first before submitting it on the fly?

Yes I did. I used Requestb.in to check that the variables are correctly inserted in the Webhook template. All is fine.

I still haven’t figured my problem out but now I know how to confirm that a webhook succeeded from the Particle Event Stream: Confirming that a webhook succeeded

Hi,

I found the problem. I come from the url field. Apparently the webhook template fails to replace the BACKAND_API_URL variable. All the other variables work fine. If I hardcode the url field, the webhook succeeds and I get the expected data from Backand.

@ScruffR You were right. I must have screwed my initial test as per your suggestion.

Apparently the url field doesn’t work with variables.

Cheers,

1 Like