I am trying to exchange information with Airtable through a webhook.
The port I am using to display the webApp is 8080 and Airtable is sending me post to http://MyIpaddress:8080.
Below is my code in the event handlers HandleURL
I don’t seem to receive the post.
Is it a problem of port setting ?
If Request.Method = “POST” Then
// Récupérer les données du formulaire envoyées par le webhook
Var largeur As String = Request.Parameter(“largeur”)
Var hauteur As String = Request.Parameter(“hauteur”)
Var couleur As String = Request.Parameter(“couleur”)
Var type As String = Request.Parameter(“type”)
// Construire le texte à afficher dans TFEcout
Var texte As String = "Largeur: " + largeur + ", Hauteur: " + hauteur + ", Couleur: " + couleur + ", Type: " + type
// Assigner la valeur au WebTextField appelé TFEcout
Données.TFEcout.Value = texte
// Répondre au serveur webhook avec un statut 200 et un message de succès
Response.Status = 200
Response.MIMEType = “text/plain”
Response.Write(“Données reçues avec succès”)
// Indiquer que la requête a été traitée avec succès
Return True
End If
// Si ce n’est pas une requête POST, retourner False pour indiquer que la requête n’a pas été gérée
Return False
If Request.Method = "POST" Then
// Récupérer les données du formulaire envoyées par le webhook
Var largeur As String = Request.Parameter("largeur")
Var hauteur As String = Request.Parameter("hauteur")
Var couleur As String = Request.Parameter("couleur")
Var type As String = Request.Parameter("type")
// Construire le texte à afficher dans TFEcout
Var texte As String = "Largeur: " + largeur + ", Hauteur: " + hauteur + ", Couleur: " + couleur + ", Type: " + type
// Assigner la valeur au WebTextField appelé TFEcout
Données.TFEcout.Value = texte
// Répondre au serveur webhook avec un statut 200 et un message de succès
Response.Status = 200
Response.MIMEType = "text/plain"
Response.Write("Données reçues avec succès")
// Indiquer que la requête a été traitée avec succès
Return True
End If
// Si ce n'est pas une requête POST, retourner False pour indiquer que la requête n'a pas été gérée
Return False
You may have already solved this, but what happens when you try hitting that address from the outside? If you are testing this by running the WebApp (‘end point’) behind your own router you’ll need to route port 8080 to your dev machines internal IP address.
I haven’t find a solution yet.
And I did route the port to my Mac.
As a matter of fact, I have done a desk App with a server socket and it’s working.
But I need to do it with a web App…
I wonder if your problem is caused by you not providing a path, so maybe try http://MyIpaddress:8080/myWebHook and set a break point in the handleURL event to see if your call makes it to the event. Obviously you’d need to modify your code there and your Airtable app to talk to that endpoint then.
I can’t find specifics in the Airtable documentation, but having built quite a number of these systems I would agree with Hanif. Many providers aren’t going to send out messages over non-standard ports like 8080 and many require SSL.
I am trying to get an answer from the company using Airtable but did not get one yet.
But beside https or http, when I use Portman to send out post to my web App, I don’t get the post. If I send the post to my desktop App listening to the same port 8080, I receive the post…
Sorry for the long time to add news. After many tests we end up to understand we had to go with HTTPS as Hanif and Tim suggested. I had to move to xojo cloud to have a https. I do receive the hook and I can answer using json text with handleURL.
Var jsonResponse As New JSONItem
jsonResponse.Value("status") = "ok"
jsonResponse.Value("message") =Repons
jsonResponse.Value("received") = True // Ajouter un champ indiquant le succès
System.DebugLog("Repons ")
//Envoyer la réponse JSON
Response.write(jsonResponse.ToString)
Response.Status = 200 // OK
I still have a problem, I need to display a drawing on the main page (with a web canvas) using some datas from the webhook sent by airtable. But I don’t know how to trigger it from handle URL?
Thanks
As soon as a request arrives to /api/test, it will update the value with the current date and time, and every observer will be notified (in this example, every browser seeing the main WebPage).
This pattern is really useful to avoid having to setup timers that are constantly checking if a value has changed. As soon as the value changes, observers will be notified.
Just for my own knowledge, is there a problem to use a timer in this case. Because it’s much easier than your solution, at least when you are no use to it…
You will be wasting CPU by polling for data changes that aren’t really changing. If there are 100 users connected to your web app, there will be 100 timers constantly checking if something has changed or not.
The other thing is, the data will be as fresh as your WebTimer.Period property is. Let’s say you set the timer period to 5000ms. Your users will have to wait up to 5 seconds to see new fresh data. Using the other method will apply any change within milliseconds, as soon as the web-hook arrives.
But other than that, if it works, it works. You can just go with the Timer way and optimize it later, if needed, and only if you want. The optimization surely can add some complexity.
I only have airtable connecting to the webApp but I understand your point. I will try to improve it and learn how to use this new feature which is always a good thing to do. Anyhow, I have to thank you because you made me find the solution.
in HandleURL, I had Imageavailable=True after drawBL() and I set up a timer
if Imageavailable=True Then
Imageavailable=False
BLC.Refresh
end