Page 1 of 1

Webhook for HTTPS

Posted: Mon Nov 26, 2018 3:07 pm
by actionHero
Has anyone been successful in configuring a Webhook in Switch? I can't even get the HTTP to work, I will eventually need the HTTPS. I've never generated a Certificate, Private Key or password before?

I've setup my HTTP webhook, using Postman to send the requests... just getting a 404 error in return.

Any suggestions?

Re: Webhook for HTTPS

Posted: Mon Nov 26, 2018 5:04 pm
by Padawan
404 means Switch doesn't know which page to serve. Have you already setup a Webhook element in one of your flows and is the flow activated?

Do you get errors in the Switch messages?

Re: Webhook for HTTPS

Posted: Mon Nov 26, 2018 5:41 pm
by actionHero
Hello,
No errors in Switch Messages.

Yes I have the webhook setup in a flow.

I'm using 'test/notify' as the URL.

My put call form Postman is http://"myIP":8080/test/notify

I get a 404 return...

If I just enter, http://"myIP":8080

I get the messages from Enfocus PDF Review Module. So I at least know it's connecting. It's just not seeing the "test/notify" in my webhook URL.

Re: Webhook for HTTPS

Posted: Mon Nov 26, 2018 5:41 pm
by actionHero
Hello,
No errors in Switch Messages.

Yes I have the webhook setup in a flow.

I'm using 'test/notify' as the URL.

My put call form Postman is http://"myIP":8080/test/notify

I get a 404 return...

If I just enter, http://"myIP":8080

I get the messages from Enfocus PDF Review Module. So I at least know it's connecting. It's just not seeing the "test/notify" in my webhook URL.

Re: Webhook for HTTPS

Posted: Mon Nov 26, 2018 6:06 pm
by jan_suhr
Are you using the WebhookRequest class in your script?

Here is an example form the manual.

Code: Select all

function webhookTriggered( s : Switch, r : WebhookRequest )
{
  if (r == null) 
  {
    try
    {
      s.webhookSubscribe(WebhookRequest.POST, "/myscript/notify");
    }
    catch(e)
    {
      s.log(3, "Error: %1", String( e ));
    }
    return;
  }
  s.log(1,"Received request using method: %1", r.method);
  s.log(1,"Request data: %1", r.getBody().toString());
  s.log(1,"Request headers: %1", JSON.stringify(r.headers));
  s.log(1,"Request query: %1", JSON.stringify(r.query));
  if ('my_header' in r.headers)
  {
    s.log(1,"Value of 'my_header': %1", r.headers.my_header);
  }
  if ('my_parameter' in r.query)
  {
    s.log(1,"Value of 'my_parameter': %1", r.query.my_parameter);
  }
}

Re: Webhook for HTTPS

Posted: Mon Nov 26, 2018 6:14 pm
by actionHero
Hi Jan,
I was just hoping to use the webhook configurator built in to Switch. Are you saying it doesn't work?

Thanks

Re: Webhook for HTTPS

Posted: Mon Nov 26, 2018 7:56 pm
by jan_suhr
actionHero wrote: Mon Nov 26, 2018 6:14 pm Hi Jan,
I was just hoping to use the webhook configurator built in to Switch. Are you saying it doesn't work?

Thanks
You posted in Scripting...

Re: Webhook for HTTPS

Posted: Mon Nov 26, 2018 11:10 pm
by Padawan
actionHero wrote: Mon Nov 26, 2018 5:41 pm Hello,
No errors in Switch Messages.

Yes I have the webhook setup in a flow.

I'm using 'test/notify' as the URL.

My put call form Postman is http://"myIP":8080/test/notify

I get a 404 return...

If I just enter, http://"myIP":8080

I get the messages from Enfocus PDF Review Module. So I at least know it's connecting. It's just not seeing the "test/notify" in my webhook URL.
Does that mean that both Switch and the PDF review module server are running on the same system and setup to listen to the same port?

If you are running them on the same server, then I would suggest to use different ports.

Re: Webhook for HTTPS

Posted: Tue Nov 27, 2018 3:20 pm
by actionHero
I did end up changing the ports and its working now. Simple fix.