Webhooks, how do they work!?
I'm pretty certain that I'm missing something here, so any help would be greatly appreciated.
I have made the following call here to make a webhook via JWT with an user account that has access to the folder.
var webhookParams = new BoxWebhookRequest { Target = new BoxRequestEntity() { Type = BoxType.folder, Id = "***number removed for privacy***05" }, Triggers = new List() { "FOLDER.CREATED" }, Address = "myurl.com/somewhere" };
await boxClient.WebhooksManager.CreateWebhookAsync(webhookParams);
But when I get the webhook's information, I notice there is way too many nulls that I figured were automatic. Which makes me think I did something wrong:
{ "Target": { "FolderUploadEmail": null, "ItemCollection": null, "SyncState": null, "HasCollaborations": null, "Permissions": null, "AllowedInviteeRoles": null, "WatermarkInfo": null, "Metadata": null, "TrashedAt": null, "PurgedAt": null, "ContentCreatedAt": null, "ContentModifiedAt": null, "CanNonOwnersInvite": null, "AllowedSharedLinkAccessLevels": null, "IsExternallyOwned": null, "SequenceId": null, "ETag": null, "Name": null, "Description": null, "Size": null, "PathCollection": null, "CreatedAt": null, "ModifiedAt": null, "CreatedBy": null, "ModifiedBy": null, "OwnedBy": null, "Parent": null, "ItemStatus": null, "SharedLink": null, "Tags": null, "Id": "***number removed for privacy***05", "Type": "folder" }, "CreatedBy": null, "CreatedAt": null, "Address": null, "Triggers": null, "Id": "69739274", "Type": "webhook" }
So anyone with experience in this arena, can you point me to in the right direction?
Also, how do I get the folder name and the folder id passed to the URL?
-
Hi, I'm Matt — I work on the Box .NET SDK and can help you out with this. The null values you see are totally normal and expected in this case, so the webhook was likely created correctly. You see the null values in this case because when the Box API returns the webhook object you created, "target" points to an object that only has the type and ID of the folder object you created the webhook — see https://developer.box.com/v2.0/reference/#create-webhook for an example. Because this is the only information that was sent back from the API, the SDK model object can only have those fields populated. When you get a webhook message at the URL you configured, you'll get a fuller payload object that includes more information about the item related to the event that triggered the webhook — see https://developer.box.com/v2.0/reference/#webhooks-v2 for more information.
-
thanks Matt for the explanation, but I'm still a bit confused. One reason is that when I call back the Webhook I created, the URL is null. How do I know what URL is being called by a webhook?
My second question is that via https://developer.box.com/v2.0/reference/#webhooks-v2, the docs start to talk about Notifications. When I configure a webhook, that's the payload data it's automatically passing? I do not need to make parameterized urls? That really makes my day if true!
Please sign in to leave a comment.
Comments
2 comments