我正在尝试使用以下代码在python的一张工作表中创建具有特定列的子范围的webhook:
my_webhook = smartsheet_client.Webhooks.create_webhook(
smartsheet.models.Webhook({
'name': 'test 10',
'callbackUrl': 'https://my_web.com/webhook/test10',
'scope': 'sheet',
'scopeObjectId': 0000000000000000,
'subscope': {'columnIds': [0000000000000000]},
'events': ['*.*'],
'version': 1
}))
当我获得成功创建的带有其ID的webhook时,响应中缺少该子范围。有人知道我在做什么错吗?
我对Smartsheet Python SDK不太熟悉,但是总的来说,每当我对如何使用SDK实施特定操作有疑问时,通常会发现查看SDK的GitHub存储库中的集成测试代码会有所帮助。在这种情况下,SDK存储库中针对Webhooks的集成测试显示了以下用于创建Webhook的代码:
def test_create_webhook(self, smart_setup):
smart = smart_setup['smart']
webhook = smart.models.Webhook()
webhook.name = 'My Webhook'
webhook.callback_url = 'https://www.smartsheet.com'
webhook.scope = 'sheet'
webhook.scope_object_id = smart_setup['sheet'].id
webhook.events.append('*.*')
webhook.version = 1
webhook.subscope = smart.models.WebhookSubscope({'column_ids': [smart_setup['sheet'].columns[0].id]})
action = smart.Webhooks.create_webhook(webhook)
assert action.message == 'SUCCESS'
assert isinstance(action.result, smart.models.Webhook)
TestWebhooks.webhook = action.result
请特别注意,subscope
设置属性的方式与上面发布的内容不同。我建议尝试在此代码之后对代码进行更多建模,以查看是否可以实现所需的结果。