Calling a Custom Webhook

732
6
Jump to solution
02-09-2021 08:41 PM
David_Vogel
New Contributor II

I am working with Survey123 and calling an Azure function as a webhook instead of using Power Automate or Integromat.     For some reason the survey can call Power Automate, but when I have it call the azure function as POST, the call never happens.  I have checked the logs on the Azure side and I see no activity at all when the survey is submitted.  The security is wide open, and I have test the function using Postman, and it works just fine.  For some reason Survery123 only wants to call Power Automate or Integromat.   I have been looking everywhere on the Survey123 webapp, and I dont see a log; does something like this exist?  Anyone have experience calling a custom webhook with Survey123?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
David_Vogel
New Contributor II

The problem was CORS.  The webhooks do not originate from the server, but from the client, in my case Chrome  Chrome by default requires a CORS to be setup. So when testing from the web browser, Chrome was blocking all calls as it was not getting a proper CORS response from Azure.   I realized this when I saw successful calls from the ios app.   Once I configured CORS for my functions, they worked fine.  This seems odd that Survey123 would depend on the client for the webhooks, and not call them from the server.  This would allow for a more consistent behavior across all platforms.   In my research there is mention of a "proxy" on the Survey123 server, but I have not found details on setting this up.

View solution in original post

Tags (3)
6 Replies
IsmaelChivite
Esri Notable Contributor

Hi @David_Vogel  Please check this blog post: https://www.esri.com/arcgis-blog/products/api-python/developers/integrating-the-arcgis-api-for-pytho... I think it should help.

For clarity: There is no reason why Survey123 should not be able call your own webhook URL. We do not block that Integromat and Power Automate.  You should be able to call other systems like Tray.io, Zapier, IFTT or like in your case, your own web service end point.  The issue is frequently on the other end: You need to make sure your server will accept requests from Survey123.  Again, I think the blog above should help. I have personally used Google functions and it works well. This video describes how you can go about them with QuickCapture, but with Survey123 it would be pretty much the same thing.

0 Kudos
David_Vogel
New Contributor II

I think I got my answer, although not completely.  For some reason the web version of a Survey does not seem to trigger the webhook, while the app version does.  I was testing with the web version, and nothing would happen.  But, when I switched the Survey123 app, the webhook was called without issue.  Is there some reason for this?

0 Kudos
MarcHoogerwerf_TAP
New Contributor II

Hi Ismael,

I have a similar issue. I have both a Make (Integromat) and an Azure Function setup as webhook. Initially I only had the Azure Function configured, but when I found out there was no activity I setup the Make flow.

The Make flow is working, but the Azure function is not. I've followed the instructions in the blog, setting up CORS to allow requests from https://survey123.arcgis.com. I've also verified that the Azure function itself is running, copying and pasting the payload in the Test/Run section.

I've also verified that the function URL was copied/pasted into the webhook configuration on the Survey123 admin page correctly, downloaded and opened up the S123 package locally and verified that the web url was referenced correctly in the package. I've deleted the form from Survey123 and downloaded it again.

But whenever I submit the form, it's only the Make flow that gets triggered. I see no invocations of the Azure functions. 

Any ideas where I could continue my investigations?

0 Kudos
David_Vogel
New Contributor II

Check out my post from 2/10.  I found out the webhook is not called from the ESRI server, but from the app or the web client.  Open up CORS to accept anything just for testing, and see if that fixes it.  At least you will have a place to start.

0 Kudos
MarcHoogerwerf_TAP
New Contributor II

Hi David,

I tried that, using just * as an entry, but that did not work. The S123 entries are made through the S123 app. I would expect that https://survey123.arcgis.com or https://services2.arcgis.com would work. But so far, no luck.

0 Kudos
David_Vogel
New Contributor II

The problem was CORS.  The webhooks do not originate from the server, but from the client, in my case Chrome  Chrome by default requires a CORS to be setup. So when testing from the web browser, Chrome was blocking all calls as it was not getting a proper CORS response from Azure.   I realized this when I saw successful calls from the ios app.   Once I configured CORS for my functions, they worked fine.  This seems odd that Survey123 would depend on the client for the webhooks, and not call them from the server.  This would allow for a more consistent behavior across all platforms.   In my research there is mention of a "proxy" on the Survey123 server, but I have not found details on setting this up.

Tags (3)