Unexpected result from webhook response [solved]

Hi There,

I’m a total noob with Particle trying to reduce my noobitude be making a fun Internet Button webhook.

The first step is to get my login working and it seems to do that, but my subscribe handler method isn’t getting called. I see the appropriate data coming back from the server (it returns json of my user object from my back end, but the name of the event doesn’t match my expectations). I’m 99.9% sure that the login is happening correctly. I call the correct url, the data is correct, and there is A return value in the event log. Here’s my code:

void setup() {
Particle.publish(“status”, “in setup”, PRIVATE);
Particle.subscribe(System.deviceID() + “/login/”, myHandler, MY_DEVICES);

const char* data =  "{\"login\":\"fake@spiralsix.com\", \"password\":\"fakepassword\"}";
Particle.publish("login", data, PRIVATE);
delay(5000);

}

void loop() {

}

void myHandler(const char *event, const char *data) {
// just publishes an event to see if the handler is called.
Particle.publish(“success”, event, PRIVATE);
}

Here is a screen shot of my event log:

The second line (lighlighted) contains JSON that is exactly the expected result of the call to login. It’s the json of my server user object. But what confuses me is that name of the even is “login/0” instead of “hook-response/login” (i think that’s what the docs said it would be.) So, how am I supposed to subscribe to that event, when the docs say it should be something else. subscribing to “login” doesn’t work.

Any help would be greatly appreciated.

Thanks community,
Peter

Okay, I found the part of the webhook setup where you can set the name of the response event. I changed it to “hook-response/login” but my handler method still doesn’t get called (and I changed the subscribe line:

Particle.subscribe(System.deviceID() + "hook-response/login", myHandler, MY_DEVICES);

So why doesn’t my handler get called?

I fixed it. The solution was:

Particle.subscribe("hook-response/login/", myHandler, MY_DEVICES);

that trailing slash worked. One of the examples had a leading slash and thats where I got hung up.

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