Skip to content

Working with webhooks

Igor Balos edited this page Dec 14, 2017 · 6 revisions

Postmark Java library allows you to easily retrieve Postmark webhooks and convert these to objects you can use within your java application.

In order to do that, we are going to share a simple example how to retrieve webhooks.

To retrieve webhooks, you can use HttpClient within Postmark Java library.

HttpClient client = new HttpClient(new MultivaluedHashMap<>());
HttpClient.ClientResponse response = client.execute(HttpClient.REQUEST_TYPES.GET, "http://webhooks-example.com");

Once you retrieved the content, all you need is to convert that response to appropriate object.

Retrieve Bounce webhook:

BounceWebhook bounceWebhook = dataHandler.fromJson(response.getMessage(), BounceWebhook.class);

Retrieve Delivery webhook:

DeliveryWebhook deliveryWebhook = dataHandler.fromJson(response.getMessage(), DeliveryWebhook.class);

Retrieve Open webhook:

OpenWebhook openWebhook = dataHandler.fromJson(response.getMessage(), OpenWebhook.class);

Retrieve Click webhook:

ClickWebhook clickWebhook = dataHandler.fromJson(response.getMessage(), ClickWebhook.class);

Clone this wiki locally