Test a WebSub/WebHook API¶
Testing a WebSub/WebHook Streaming API refers to the process of trying out a WebSub/WebHook API at the Developer Portal and making sure that the functionalities and behaviors are correctly met.
Follow the instructions below to test a WebSub API (WebHook API):
Prerequisites
-
The WebSub/WebHook API should have been published.
-
The WebSub/WebHook API topic should have been registered with your WebHook provider. For more details, see Create a WebSub/WebHook API.
The examples here use the RepoWatcher
WebSub/WebHook API, which was created in Create a WebSub/WebHook API.
-
Sign in to the Developer Portal.
https://<hostname>:9443/devportal
For testing purposes, you can use
https://localhost:9443/devportal
andadmin
as the username and password. -
Click on the WebSub/WebHook API.
The API overview appears.
-
Click Try Out and go to the Try Out section.
-
Generate the access token.
-
Select OAuth as the Security Type and select DefaultApplication as the Application.
-
Select Production as the Key Type, and click GET TEST KEY.
The access token will be generated.
-
-
Create a callback URL.
-
Go to https://webhook.site.
-
Click New, leave the default values, and click Create.
A unique URL will be created for you.
-
Click Copy to clipboard, which is next to Your unique URL.
-
URL-encode the URL, which you have copied.
-
-
Subscribe to a topic.
-
Generate the cURL command to subscribe to the topic
Follow the instructions below to generate the cURL command to subscribe to a topic:
-
Go back to the Developer Portal.
-
Expand the /issues topic.
-
Select Subscribe.
-
Provide the encoded callback URL which you have obtained in the previous step, as the Callback URL.
-
Click GENERATE CURL. The cURL command will be generated.
-
Copy the generated cURL command, paste it into a terminal, and execute it.
-
-
Click Subscriptions to go to the Subscriptions page of your application in the Developer Portal.
-
Click on the WebSub/WebHook API's subscription entry.
This lists down the subscription you just made.
You have now registered the given callback URL with the /issues topic. Triggering your WebHook will send an event to the callback URL.
-
-
Unsubscribe from a topic.
-
Generate the cURL command to unsubscribe from a topic.
Follow the instructions below to generate the cURL command to unsubscribe from a topic:
-
Expand the /issues topic in the Developer Portal.
-
Select Unsubscribe.
-
Provide the encoded callback URL which you have obtained previously, as the Callback URL.
-
Click GENERATE CURL.
The cURL command will be generated.
-
Copy the generated cURL command, paste it into a terminal, and execute it.
-
-
Click Subscriptions to go to the Subscriptions page of your application in the Developer Portal again.
-
Click on the WebSub/WebHook API's subscription entry.
The subscription you made previously will not be displayed in the list anymore.
You have now unsubscribed the given callback URL from the /issues topic.
-