B4J Question Webhook service support


Active Member
Licensed User
Longtime User
Hi, I would like to add webhook support to one of my B4J Server application.
I've not found anything about services, only client side.

Does anyone has an idea or piece of code to start from?
Can I achieve that with regular server code, or should I look at additional components?

Many thanks in advance


Active Member
Licensed User
Longtime User
I mean this:

I did more research and essentially what I have to do in B4J is just to add the following:
srvr.AddHandler("/webhook", "Webhook", False)
Then I create a new class module called Webhook doing things based on the specific method/headers/payload that the calling service will generate and sending a response as the calling service expects to acknowledge I have received the call.
'Class module
Sub Class_Globals
    Private mreq As ServletRequest        'ignore
    Private mresp As ServletResponse    'ignore
End Sub

Public Sub Initialize

End Sub

Sub Handle(req As ServletRequest, resp As ServletResponse)
    mreq = req
    mresp = resp
    Dim method As String
    Dim response_type As String
    Dim clientid As String
    method = req.Method                    'Collect the Http method
    Log(method & " " & req.FullRequestURI)
    clientid = req.GetHeader("x-tropical-clientid")
    Log("x-tropical-clientid: " & clientid)
    response_type = req.GetParameter("response_type")
    Log("response_type: " & response_type)
    resp.SetHeader("x-tropical-clientid", clientid)
End Sub
Upvote 0