Implemented a Service to receive real time message from an API Webhook

 What is the webhook?  Ask Google :) 😅 

This is my experience to build a Azure Function HTTP trigger to receive an event from SkyBox API Webhook. 

Business requirement: Real time integration INVOICE with SkyBox API Webhook. Means whenever SkyBox has a new or Update invoice. Their service would send the json message to my API.


Solution: 

Step 1: Built C# HTTP trigger function and then deploy it to Azure Function


Depends on the business requirement, you can add more in your own code.

 Step 2: Added a subscription sending a POST to https://skybox.vividseats.com/services/webhooks

{

 "topic": "INVOICE",
 "url": "https://xxxxxxxxinvoice.azurewebsites.net/api/SkyboxReceiveInvoice?code=xxxxxxxxxx",
 "headers": "Bearer: xxxxxxxx",
 "secret": "yoursecretkey"
}

Navigate to Azure Function Monitor to see the message coming.

Note:

The "secret": "yoursecretkey" is using for Encrypted the message. Here is code:

+ Create Key:
byte[] key = Encoding.ASCII.GetBytes("TicketShine");

+ Encode to create a check MAC.

public static string Encode(string input, byte[] key)
{
HMACSHA1 myhmacsha1 = new HMACSHA1(key);
byte[] byteArray = Encoding.ASCII.GetBytes(input);
MemoryStream stream = new MemoryStream(byteArray);
return myhmacsha1.ComputeHash(stream).Aggregate("", (s, e) => s + String.Format("{0:x2}", e), s => s);
}

Comments

Popular posts from this blog

Featured Projects: Automation and AI Systems I Built and Run

AWS API gateway, S3

Business case: Monitor mailbox and auto-save the attachment to a SharePoint