Web Hooks
First we are going to need to make a production key. Go to the WSO2 API store and click on my subscriptions.
Then, make sure you are generating keys for your application and generate keys.
Search for the Event Hub in the API store.
Make sure you are in production. Subscribe to the Event Hub on the unlimited tier.
Let’s subscribe to the Name Changed event. This means that your personal queue (in production) will fill up with events raised when a name is changed.
Those items in the queue need somewhere to go, so let’s make a webhook that will tell it where to send information.
Go to the webhooks section and click on the post method. You can put in your information, but before we move on, let’s talk about what is going on.
The naming conventions of event hub are a little strange, so bear with me.
You are the “entity”, so that is going to be your BYU ID and name in the first two.
The endpoint is where you want Event Hub to send requests to. In our case it will be our server on the “/changed_name” path.
Event Hub has a few options for how you can deal with the information that it sends. It has a queue of all your pertinent events that it is waiting to send. However, it wants to be sure that you’ve received them. There are a few way to deal with this is the “Push Message” option, which will keep sending your API the last item of the queue until you respond saying that you got it. To do that you have to send back a 200 status code.
Event Hub does not send a JWT to confirm that it is safe, instead it uses HMAC security, which we will figure out later.
Finally, the last section indicates that your API will be receiving your data in the form of a JSON.
Click “Try it out!” to subscribe to the webhook. If you want to go check your logs on the Elastic Beanstalk so you can see that they are coming you can do that.
If you want you can go back at any time and see what webhooks you’ve set-up with a GET request and your BYU ID.
Note that in the data received you can see your webhooks security key. You will need that later.
Great! It’s all set up!
Just as a reference, this is what Event Hub sends in the body of it’s requests that it send to your API. (Here is the event generated when I changed my first name to Calvino)