2.1 How to | Making sure your webhook works correctly - Hopeful-Developers/topggwebhooks4j GitHub Wiki

How do I make sure my webhook works correctly?

After making your webhook, you need to make sure that it works correctly and is ready to receive webhook requests. You can do so by using reqbin or Postman to make a test request to your newly created webhook. Though for the sake of this tutorial, we're going to use reqbin for now.

Testing

First of all, get your webhook url: Normally it could be http://yourip:port/context replacing yourip with the IP your webhook is hosted on, port with what port you're using in your setPort(int) method, and context the first parameter of either your addGuildListener or addBotListener method.

Something like http://91.12.34.56:8080/MyWebhook would be a working example.

Disclaimer: something like 0.0.0.0 or localhost are not valid IPs to use for making test requests: 0.0.0.0 is defined as "being able to connect to it from anywhere, like a domain or an IP, not being bound to anything". localhost only works on your local machine, the only way to test using localhost is with postman, as the requests you're making are local.

Lets use http://91.12.34.56:8080/MyWebhook as an example on how you can test your webhooks:

Upon visiting reqbin, you're greeted with this site:

reqbin example

on that site, you need to fill out the following:

  • Your webhook url on the URL field
  • the Request Method POST, as we want to send data through the webhook

example filling

Now we're going to start with filling out your Authorization:

The Authorization is what you have defined on either your addGuildListener or addBotListener method on the authorization field, which is the last parameter: