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.
A webhook infocan be retrieved by calling the getInfo(String...)
method.
BoxWebHook webhook = new BoxWebHook(api, id);
BoxWebHook.Info info = weghook.getInfo();
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.
}
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);
A webhook can be deleted by calling the delete()
method.
BoxWebHook webhook = new BoxWebHook(api, id);
webhook.delete();
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);