日本時間5月16日のContent Cloud Summitで、カスタムアプリにBox AI APIを活用する方法を紹介します。

詳細を表示

Webhookの更新

Webhookの更新

Webhookは、開発者コンソールまたはAPIを使用して更新できます。

開発者コンソール

開発者コンソールでWebhookを更新するには、以下の手順に従います。

  1. 開発者コンソールの [Webhook] タブに移動し、すべてのWebhookを表示します。
  2. WebhookのIDをクリックして、更新するWebhookを選択します。
  3. [Webhookを編集] ボタンをクリックします。
  4. 更新するデータを入力します。
  5. [更新] ボタンをクリックして変更を保存します。

Webhookのリストには、[ID]、[アドレス]、[コンテンツ]、[作成者]、[作成日] フィールドがあります。

API

Webhookを更新するには、Webhookを更新エンドポイントを使用します。それにはWebhook IDが必要です。WebhookのIDを調べるには、すべてのWebhookのリストを取得エンドポイントを使用します。

cURL
curl -i -X PUT "https://api.box.com/2.0/webhooks/3321123" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "triggers": [
         "FILE.DOWNLOADED"
       ]
     }'
.NET
var updates = new BoxWebhookRequest()
{
    Id = "12345",
    Address = "https://example.com/webhooks/fileActions
};
BoxWebhook updatedWebhook = await client.WebhooksManager.UpdateWebhookAsync(updates);
Java
BoxWebHook webhook = new BoxWebHook(api, id);
BoxWebHook.Info info = webhook.new Info();
info.setAddress(url);
webhook.update(info);
Python
update_object = {
    'triggers': ['FILE.COPIED'],
    'address': 'https://newexample.com',
}
webhook = client.webhook(webhook_id='12345').update_info(data=update_object)
print(f'Updated the webhook info for triggers: {webhook.triggers} and address: {webhook.address}')
Node
client.webhooks.update('678901', {address: "https://example.com/webhooks/fileActions"})
	.then(webhook => {
		/* webhook -> {
			id: '1234',
			type: 'webhook',
			target: { id: '22222', type: 'folder' },
			created_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			created_at: '2016-05-09T17:41:27-07:00',
			address: 'https://example.com/webhooks/fileActions',
			triggers: [ 'FILE.DOWNLOADED', 'FILE.UPLOADED' ] }
		*/
	});
iOS
client.webhooks.update(webhookId: "1234", targetType: "file", targetId: "1234", address: "www.testurl.com") { (result: Result<Webhook, BoxSDKError>) in
    guard case let .success(webhook) = result else {
        print("Error updating webhook")
        return
    }

    print("Updated webhook address to \"\(webhook.address)\"")
}