Implementations

Resthooks with ASP .NET Core on the example of Infusionsoft

By on 07/10/2017

Many platforms and networks support a technique called RestHooks, which is basically just an event or trigger from that platform when certain actions or changes took place. It is mainly meant for reducing polling and avoiding the implementation of more complex solutions like RabbitMQ or SignalR. Also, it works nicely together with OAuth authentication, which needs to be implemented before. For running the example in this post, you can just copy in an existing token that you have.

Currently working with Infusionsoft and ASP .NET Core, I couldn’t find any documentation specifically for this solution. So after solving it, I want to offer it to anyone who has to solve it as well.

First you have to understand the flow of the hook creation and verification, before implementing it. But it’s pretty straight-forward. You should know that there are 2 ways of verifying requests – the immediate (synchronuous) and delayed verification. This describes the synchronuous implementation.

  1. You POST a hook request to Infusionsoft
  2. During this request, Infusionsoft calls to your controller (configured in the request) to verify the request.
  3. From there, you have to respond with the same secret that Infusionsoft sends you.
  4. You get the response for your original POST, which includes the hook info with the status ‘verified’
  5. Now the hook is set up. Events that happen in Infusionsoft…
  6. Are forwarded to you to the same callback url that was used for verification

In case of delayed (asynchronuous) verification, the call to your callback url (step 2) is not answered, or not with the expected secret. In that case, the token getting back to you in step 4 is ‘unverified’. In order to verify the hook at a later point in time, you have to call the delayedVerify endpoint.

In the following Gist, you can see all the implementations of this example.

HAPPY PLANTING

TAG