question

matt avatar image
matt asked matt commented

Problem with webhooks using Django

I have configured webhooks on the sandbox dashboard using this address:

https://a0357b1xxxxx.ngrok.io/api/v1/wh/

I received the verification code and used it to finalize the setup procedure.

However I have problems when receiving the webhook requests when something changed on Clover POS. I use ngrok for my dev machine and see on the ngrok web interface that I get 404 errors when Clover sends requests to my webhook route. I get some html as response from Django including this

<th>Request URL:</th>
        <td>http://a0357b1xxxxx.ngrok.io/https:/a0357bxxxx.ngrok.io/api/v1/wh/</td>

It is strange that there is a http and then https address. When I make a Postman request to https://a0357bxxxx.ngrok.io/api/v1/wh/ everything works as expected.

So I wonder what is the difference of Clovers request for the verification code (which works) and the other requests including the notifications. I saw another thread

https://community.clover.com/questions/13362/clover-webhooks-wrong-callback.html

but the problem seems different with double https in the URL.

Unfortunately, links are not available in the old community posts and it's unclear what webhook tester was recommended.



Webhooks
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

If we are delivering the message it sounds like something on your end. Is Raymond's answer in the link you posted something you have investigated?

Both types of POST requests are valid, its just a matter of the request using the relative url vs the absolute url.The reason you are getting a 404 is on the django side, as you should be able to handle both types of urls.I would double check that you are not assuming your url will be relative, and building an absolute path out of it, as that would cause the " https://solestage.ngrok.io/ https://solestage.ngrok.io/api/clover/" url that you are suspecting.Django by default should already handle both absolute and relative urls correctly (see here), as long as your urlpatterns are set up correctly.


0 Likes 0 ·

1 Answer

matt avatar image
matt answered matt commented

I found out that one has to use the host-header option of ngrok

./ngrok http -host-header=rewrite 127.0.0.1:8000

2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

This resolves your issue?

0 Likes 0 ·
matt avatar image matt David Marginian ♦♦ commented ·

Yes! It seems that the original URL that Clover directs to is included in the forwarded request of ngrok to my local dev server. With this option it is obviously possible to get rid of the wrong address

0 Likes 0 ·

Welcome to the
Clover Developer Community