K Khan
Jan 4, 2016
  2969
(1 votes)

Integrate solutions via aspnet webhooks

Webhooks are "user-defined HTTP callbacks". They are usually triggered by some event, such as pushing code to a repository or a comment being posted to a blog. When that event occurs, the source site makes an HTTP request to the URI configured for the webhook. Users can configure them to cause events on one site to invoke behaviour on another. The action taken may be anything. Common uses are to trigger builds with continuous integration systems or to notify bug tracking systems. Since they use HTTP, they can be integrated into web services without adding new infrastructure.

WebHook framework for ASP.NET (available in pre release at Nuget) gives you a pattern for:

  • Handling subscriptions from interested subscribers
  • Sending subscriptions to publishers
  • Sending published messages to subscribers
  • Handling publisher messages from subscribed services (via Receivers)

Image 20160101_100939-1.jpg

To fit this with EPiServer I have developed a Storage manager based on EPiServer DDS and Controller to deal with sunbscribers. This blog is to get the initial feed back that what general events clients will like to subscribe generally, Code is available on git. I am still working on an interface to allow editors to subscribe other websites.

With current solution solution,To make a sender application you will require to add dlls in your server. Using this Javascript subscribers can be added. I am using Alloy site.

<script>
    function subscribe() {
    $.ajax({
        type: "POST",
        url: "/api/EpiServerWebHookRegistrations/Subscribe",
        data: JSON.stringify({
            WebURI: "http://localhost:51481",
            Secret: "12345678901234567890123456789012",
            Description: "WebHook for entry updating!",
            Services: "contentschanged"
        }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(data, status) { alert(data.Message ? data.Message : status); },
        error: function (errMsg) { alert(errMsg.responseJSON.Message); }
    });
    return false;
}

function unsubscribe() {
    $.ajax({
        url: "/api/webhooks/registrations",
        type: 'DELETE',
        success: function (data, status) { alert(data.Message ? data.Message : status); },
        error: function (errMsg) { alert(errMsg.responseJSON.Message); }
    });
    return false;
}

</script>

To implement receiver you will have to implement a handler and few settings in web.config. (Please see this blog)

and Happy New Year!

Jan 04, 2016

Comments

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024