Yes, the DELIVERY_ADDRESS is your web address. If you run it on your local machine, you can use ngrok tunnel to make it accessible from outside.
The default value of "expiresIn" is 7 days (in seconds). The max value can be up to 20 years (in seconds)
The notification events (with payload) will be sent to your DELIVERY_ADDRESS, be it at the place you run the code to start the subscription or somewhere remotely. The most important thing is to return a verification-token within 5 secs after you subscribe for a notification. See the quick start example.
Hi Phong,
Thanks for the response. Can you clarify what you mean by "return a verification-token within 5 secs after you subscribe for a notification".
The SubscriptionInfo returned from posting a CreateSubscriptionRequest doesn't return a verification-token. The NotificationDeliveryModeRequest accepts a verificationToken. Do I need to set this token with the token returned from the restClient.Authorize method before making the request?
app.Run( async (context) =>
{
context.Request.Headers.TryGetValue("Validation-Token", out StringValues validationToken);
context.Response.Headers.Add("Validation-Token", validationToken);
if (context.Request.Path == "/webhook" && context.Request.Method == "POST")
{
using (StreamReader reader = new StreamReader(context.Request.Body, Encoding.UTF8))
{
var str = reader.ReadToEnd();
Console.WriteLine(str);
}
}
});
In the quick start example, there are 2 processes, the "Startup.cs" server is running and listening on a local machine on port 5000. The other process "Program.cs" is run once to subscribe for notification. You can run the 2 processes from different machines, e.g. run the "Program.cs" in your local machine and the "Startup.cs" on your remote server. The "Startup" process return the validation-token in the header as highlighted above. The 5 secs is the period of time between the "Program" process starts subscribing for notifications and the "Startup" process receives and sets the validation-token.
Thanks Phong.
Please confirm that I execute this code in my C# API controller instead of in the Startup file.