Samples
CSharp
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using System.ComponentModel.DataAnnotations;
namespace WIS_Webhook_Sample
{
public class WisEvent
{
public required string TaskId { get; set; }
public required string Status { get; set; }
}
public class WisEventWebhookResponse
{
public required string TaskId { get; set; }
}
}
namespace WIS_Webhook_Sample.Controllers
{
[ApiController]
[Route("[controller]")]
public class WisEventWebhookController : ControllerBase
{
[ProducesResponseType(typeof(WisEventWebhookResponse), StatusCodes.Status200OK)]
[HttpPost(Name = "WisEventWebhook")]
public IActionResult Post(WisEvent myEvent, [FromHeader(Name = "x-auth-token")][Required] string authToken)
{
// Check that the event comes from WIS by checking x-auth-token
if (authToken != "YOUR TOKEN HERE")
{
return new UnauthorizedObjectResult(new { error = "Wrong x-auth-token" });
}
// you can do some processing there
// (in our example, we print the task's id and the status in the console)
Console.WriteLine(string.Format("Task {0} is now {1}.", myEvent.TaskId, myEvent.Status));
// --
// The route MUST return the event
return this.Ok(new WisEventWebhookResponse { TaskId = myEvent.TaskId });
}
}
}NodeJS/Typescript
WebhookHandler.ts
webhook_endpoint.ts
Last updated