Warm tip: This article is reproduced from serverfault.com, please click

Smartsheet webhook subscope

发布于 2020-11-30 09:04:49

I'm trying to create a webhook with subscope of a specific column in one of my sheets in python with the following code:

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

And when I get the successfully created webhook with its ID, the subscope is missing from the response. Does anyone have a clue what am I doing wrong?

Questioner
Amit Dahan
Viewed
0
Kim Brandl 2020-12-01 01:02:30

I'm not very familiar with the Smartsheet Python SDK, but in general, I often find it helpful to look at the integration test code in the SDK's GitHub repo whenever I have a question about how to implement a certain operation using the SDK. In this case, the integration test for webhooks in the SDK repo shows the following code for creating a 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

Notice specifically that the way the subscope property is being set differs from what you've posted above. I'd suggest trying to model your code more after this code, to see if you can achieve the desired outcome.