This sample application demonstrates how to receive webhooks from Xero:
- Accept a POST request from Xero
- Verify the payload signature
- Store the payload to a queue for future asynchronous processing
- Respond with the correct HTTP status code
- A private or partner app connected to at least one Xero Organisation, to generate webhook events (https://developer.xero.com/myapps)
- A subscription for your app subscribed to contact events (https://developer.xero.com/myapps)
- .NET Core for your preferred platform (https://www.microsoft.com/net/download/core)
- ngrok, to tunnel network traffic to localhost (https://ngrok.com/)
You can choose whether to run this sample application from the packaged executable, or build and run it from the source code. If you're unfamiliar with .NET Core we recommend the executable.
- Download the packaged executable and unzip to a directory of your choice.
- Update
appsettings.json
with your Webhook key to hold the key for your subscription. This can be found by browsing to your app at https://developer.xero.com/myapps and selecting the webhooks tab. - Open a terminal in the directory and execute
dotnet XeroWebhooksReceiver.dll
. This will start a local web server (e.g. http://localhost:5000). - Make your server accessible from Xero as described below.
- Clone this repository.
- Open the solution in a compatible IDE (e.g. Visual Studio Community Edition)
- Update
appsettings.json
with your Webhook key to hold the key for your subscription. This can be found by browsing to your app at https://developer.xero.com/myapps and selecting the webhooks tab. - Build the solution.
- Run the solution. This will start a local web server (e.g. http://localhost:5000).
- Make your server accessible from Xero as described below.
- Download ngrok from https://ngrok.com/ and unzip to a directory of your choice.
- Open a terminal in the directory and execute
./ngrok http --bind-tls=true 5000
. Ngrok will provide you with a https URL (e.g. https://daaf38b6.ngrok.io). - Set your app's webhook delivery URL to {ngrok_address}/webhooks (e.g. https://daaf38b6.ngrok.io/webhooks) in the developer portal.
- Create or modify any contact in a Xero Organisation connected to your app and wait for the event to arrive at your XeroWebhooksReceiver server.
Project | Description |
---|---|
XeroWebhooksReceiver |
Web server and business logic |
WebhooksDataContracts |
Data model classes |
Tests/XeroWebhooksReceiverUnit.Tests |
Unit tests |
Tests/XeroWebhooksReceiverIntegration.Tests |
Integration tests |