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

詳細を表示

Webhookを更新

put
https://api.box.com/2.0
/webhooks/:webhook_id

Webhookを更新します。

リクエスト

bearer [ACCESS_TOKEN]
application/json

パスパラメータ

stringパス内必須
3321123

WebhookのID。

リクエスト本文

string本文内省略可能
"https://example.com/webhooks"

このWebhookによって通知されるURL

object本文内

Webhookをトリガーする項目

string本文内省略可能
"1231232"

Webhookをトリガーする項目のID

string本文内省略可能
"file"

Webhookをトリガーする項目のタイプ

次の値のいずれか1つ: file,folder

string array本文内省略可能
["FILE.UPLOADED"]

このWebhookがトリガーされるイベント名の配列

レスポンス

application/jsonWebhook

新しいWebhookオブジェクトを返します。

パラメータが正しくなかった場合は、エラーを返します。

アプリケーションにWebhookを管理する権限が付与されていない場合は、エラーを返します。

ターゲットの項目またはWebhookが見つからなかった場合は、エラーを返します

同じターゲット、アプリケーション、ユーザーの組み合わせのWebhookがすでに存在する場合は、エラーを返します。

予期しないクライアントエラー。

put
Webhookを更新
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

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)\"")
}

レスポンスの例

{
  "id": "11446498",
  "type": "webhook",
  "address": "https://example.com/webhooks",
  "created_at": "2012-12-12T10:53:43-08:00",
  "created_by": {
    "id": "11446498",
    "type": "user",
    "login": "ceo@example.com",
    "name": "Aaron Levie"
  },
  "target": {
    "id": "1231232",
    "type": "file"
  },
  "triggers": [
    "FILE.UPLOADED"
  ]
}