How to Receive Webhooks on an HTTP Endpoints with TMS Components WebCore/XData

Is it possible to receive Webhooks on an HTTP Endpoint in an vcl application like an xdata-webservice?

i tried to redirect the webhook to my xdata webservice but this rises an urlpath error.

do i something wrong or is there another possibility to catch the web push notification on an URL?

Thx Jörg

Yes, a webhook is simply a request to an HTTP server. If you have an HTTP server running, then you can receive requests on it.

If you receive an error that mentions "urlpath", then it hints the URL is wrong. I cannot guess much more things without further details.

I created this procedure in my service
[httpPost]
procedure eterminPush (atext : string);
to receive the webhook

and this is the kind of request that will be send to the url:
"# Webhooks - Push Webhook
eTermin will send a POST request to the address you have specified once an appointment got created/modified/deleted. You can specify the address in the "Configuration->Integration - API->API" tab. This request contains the following information: { some kind of variables send as String }

eTermin gives this example in c#

public class Handler1 : IHttpHandler
	{
	  public void ProcessRequest(HttpContext context)
	  {
		try
		{
		  string appointmentUID = context.Request.Form["APPOINTMENTUID"].ToString();
		  DateTime startDateTimeUTC = DateTime.ParseExact(context.Request.Form["STARTDATETIMEUTC"], "yyyyMMdd HHmmss", CultureInfo.CurrentCulture);
		  DateTime endDateTimeUTC = DateTime.ParseExact(context.Request.Form["ENDDATETIMEUTC"], "yyyyMMdd HHmmss", CultureInfo.CurrentCulture);
		  DateTime startDateTime = DateTime.ParseExact(context.Request.Form["STARTDATETIME"], "yyyyMMdd HHmmss", CultureInfo.CurrentCulture);
		  DateTime endDateTime = DateTime.ParseExact(context.Request.Form["ENDDATETIME"], "yyyyMMdd HHmmss", CultureInfo.CurrentCulture);
		  DateTime bookingDateUTC = DateTime.ParseExact(context.Request.Form["BOOKINGDATEUTC"], "yyyyMMdd HHmmss", CultureInfo.CurrentCulture);
		  string salutation = context.Request.Form["SALUTATION"].ToString();
		  string lastName = context.Request.Form["LASTNAME"].ToString();
		  string firstName = context.Request.Form["FIRSTNAME"].ToString();
		  string email = context.Request.Form["EMAIL"].ToString();
		  string phone = context.Request.Form["PHONE"].ToString();
		  string street = context.Request.Form["STREET"].ToString();
		  string ZIP = context.Request.Form["ZIP"].ToString();
		  string town = context.Request.Form["TOWN"].ToString();
		  string birthday = context.Request.Form["BIRTHDAY"].ToString();
		  string notes = context.Request.Form["NOTES"].ToString();
		  string customerNumber = context.Request.Form["CUSTOMERNUMBER"].ToString();
		  string additional1 = context.Request.Form["ADDITIONAL1"].ToString();
		  string additional2 = context.Request.Form["ADDITIONAL2"].ToString();
		  string additional3 = context.Request.Form["ADDITIONAL3"].ToString();
		  string additional4 = context.Request.Form["ADDITIONAL4"].ToString();
		  string additional5 = context.Request.Form["ADDITIONAL5"].ToString();
		  string additional6 = context.Request.Form["ADDITIONAL6"].ToString();
		  string selectedAnswers = context.Request.Form["SELECTEDANSWERS"].ToString();
		  string bookingLanguage = context.Request.Form["BOOKINGLANGUAGE"].ToString();
		  string calendarName = context.Request.Form["CALENDARNAME"].ToString();
		  context.Response.StatusCode = 200;
		  context.Response.SuppressContent = true;
		  context.ApplicationInstance.CompleteRequest();
		  /*
			// Insert in DB
			string connectionString = "";
			System.Web.UI.WebControls.SqlDataSource dsInsert = new System.Web.UI.WebControls.SqlDataSource(connectionString, "");
			dsInsert.InsertCommand = "INSERT INTO ...";
			dsInsert.InsertParameters.Add("appointmentUID", appointmentUID);
			dsInsert.InsertParameters.Add("startDateTimeUTC", System.Data.DbType.Date, startDateTimeUTC.ToShortDateString());
			dsInsert.Insert();*/
		}
		catch (Exception e)
		{
		  System.Diagnostics.Debug.WriteLine(e.Message);
		  //context.Response.StatusCode = 400;
		  //context.Response.SuppressContent = true;
		  //context.ApplicationInstance.CompleteRequest();
		}
	  }
	}

I Told eTermin send the Webhook to this URL : http://+IP+:2001/AOPEOSERVER/eTerminPush

and i recieve this message in etermin:"Failed The remote server returned an error: (404) Not Found.
{ "error": { "code": "UrlInfoError", "message": "Unknown path "eTerminPush"" } } "
and this in my service: EXDataHTTPURLInfoErrow : Unknown Path "eTerminPush"

Note that the default routing for XData services is <service name>/<method name> as explained here:

https://doc.tmssoftware.com/biz/xdata/guide/service.html#default-routing

Thus the correct URL is not just /AOPEOSERVER/eTerminPush, but /AOPEOSERVER/<service_name>/eTerminPush, where <service_name> is the name of your interface without the leading I.

Thats it! Thank you very much. Now i receive the data :slight_smile:

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.