Bug in Rest API Patch Webhook
Posted: Wed Mar 03, 2021 11:02 am
In terms of the webhook patch I have discovered two things that are an issue, the first is that if you don't set the patch body as Json in postman it doesn't make it through the serialisation process and you get null reference exceptions, this I can understand as it probably means postman is not sending the appropriate content headers without this setting.
The second issue is definitely a bug as I have checked the code and that is a patch won't do anything with the headers in the payload in other words this bit from the post or the equivalent for the patch is missing
The second issue is definitely a bug as I have checked the code and that is a patch won't do anything with the headers in the payload in other words this bit from the post or the equivalent for the patch is missing
- Code: Select all
// Now do the headers (if any)
if (request.Headers != null)
{
foreach (WebhooksSubscriptionHeader webhooksSubscriptionHeader in request.Headers)
{
string webhooksSubscriptionHeaderRecID = System.Guid.NewGuid().ToString();
Db.ExecuteSql(@"INSERT INTO SY_WebhookSubscriptionRequestHeader (RecID, SY_WebhookSubscription_RecID, Name, Value, ItemNo, LastSavedDateTime)
VALUES (@RecID, @SY_WebhookSubscription_RecID, @Name, @Value, (SELECT COALESCE(MAX(ItemNo), 0) + 1 FROM SY_WebhookSubscriptionRequestHeader WHERE SY_WebhookSubscriptionRequestHeader.SY_WebhookSubscription_RecID = @ItemNo_SY_WebhookSubscription_RecID), SYSUTCDATETIME())",
new
{
RecID = webhooksSubscriptionHeaderRecID,
SY_WebhookSubscription_RecID = newSubscription.RecID,
Name = webhooksSubscriptionHeader.Name,
Value = webhooksSubscriptionHeader.Value,
ItemNo_SY_WebhookSubscription_RecID = newSubscription.RecID
});
SY_WebhookSubscriptionRequestHeader newSubscriptionRequestHeader = Db.SingleById<SY_WebhookSubscriptionRequestHeader>(webhooksSubscriptionHeaderRecID);
RESTAPIPlugin.WebhookSubscriptionRequestHeaders.Add(newSubscriptionRequestHeader);
}
}