Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 2.46 KB

webhooks.md

File metadata and controls

75 lines (53 loc) · 2.46 KB

Webhooks

Webhooks enable you to attach event triggers to Box files and folders. Event triggers monitor events on Box objects and notify your application when they occur. A webhook notifies your application by sending HTTP requests to a URL of your choosing.

Get a Webhook

A webhook infocan be retrieved by calling the getInfo(String...) method.

BoxWebHook webhook = new BoxWebHook(api, id);
BoxWebHook.Info info = weghook.getInfo();

Get All Webhooks

Calling the static all(BoxAPIConnection, String...) will return an iterable that will page through all defined webhooks for the requesting application and user.

Iterable<BoxWebHook.Info> webhooks = BoxWebHook.all(BoxAPIConnection api);
for (BoxWebHook.Info webhookInfo: webhooks) {
    // Do something with the webhook.
}

Create a Webhook

The static create(BoxResource, URL, BoxWebHook.Trigger...) method will let you create a new webhook for a specified target object.

BoxFolder folder = new BoxFolder(api, id);
BoxWebHook.Info webhookInfo = BoxWebHook.create(folder, url, BoxWebHook.Trigger.FILE_UPLOADED);

Delete a Webhook

A webhook can be deleted by calling the delete() method.

BoxWebHook webhook = new BoxWebHook(api, id);
webhook.delete();

Update a Webhook

A webhook can be updated by calling the update(BoxWebHook.Info) method.

BoxWebHook webhook = new BoxWebHook(api, id);
BoxWebHook.Info info = webhook.getInfo();
info.addPendingChange("address", url);
webhook.update(info);