Select to view content in your preferred language

Pull Data from Feature Layer based on Survey 123 Webhook

845
3
08-11-2023 09:35 AM
JeffSilberberg
Frequent Contributor

 

I am attempting to retrieve a few columns from a Feature Layer that was created from an Excel worksheet and is now maintained through Survey 123 using the inbox feature.

I have added a Webhook and pointed it to a boilerplate PHP that captures the post and sends the data to me via email.   The JSON makes sense more or less, but I am having trouble understanding the linkage to the feature layer.  

In the JSON I have a Global Id but this does not seem to tie to the Item Id for the Feature Layer and then I have an FID which, while I am not far along enough to be sure, expect will tie to the record.  

My ultimate goal is to retrieve four columns from the Record updated to use in an API Post to another system.  

Is this the right documentation for this query ?
 http://gisweb.dotd.la.gov/arcgis/SDK/REST/index.html?fsupdate.html

TIA - 

 

 

 

 

 

0 Kudos
3 Replies
ZacharySutherby
Esri Regular Contributor

Hello @JeffSilberberg

There is no linkage between the webhook and the feature service. When a webhook is configured with a Survey123 survey, when Survey123 submits a response it sends an applyEdits request to the feature service, then sends a seperate request to the payload URL for the feature service with the same JSON send to the applyEdits endpoint. 

The /updateFeatures REST API resource would be used if you wanted to update the data in the feature service. If you just need the data that exists in the record you can use the /query API endpoint. 

Thank you,
Zach
JeffSilberberg
Frequent Contributor

@ZacharySutherby 

    Thank you for the response.  It is the Query API endpoint that I am attempting to use, but I am trying to query five fields in the row (or is it layer) that a Survey 123 user just updated.   

     The Survey 123 works fine, the Webhook fires correctly, and I see the JSON as expected in the target of the Webhook URL which is for now trapJSON.php. 

    The next step in the flow is to retrieve some static information from the row being updated and use the data to reset the related line crossing analytics in a video system.  

  I am struggling with two things here -- based on the Feature Service Layer Query documentation at the link you and others have provided. 

  • What exactly is the Feature-Layer-URL I need to be using? I have tried a couple of variations manually in Postman and always get back not found bad URL error, or some other similar error.  By the way, I struggled with this same issue in Survey 123 Connect until someone helped/pointed me at a sample to base its construction on.  It would be nice if the "Item Details" or the subpage "ArcGIS Rest Services Directory" Service Overview" provided more insight or even some links that could be copy pasted.  
  • My second issue here is that in all data provided in the WebHook (Right now I have checked all the options), it is not at all clear as to what I use to get the one row and outfields I need back from the post. Is it an ObjectIds={webhookvalue} value for a WHERE =Gobalid={Hook_Global_id}.  or is there some other primary/unique key element that I am missing to form a select / join/where Query?  

  Thank you for your assistance here - 

PS: the outfields=a,b,c,f  makes sense to me if I can ever get that far-

 

0 Kudos
JeffSilberberg
Frequent Contributor

I got this to work thanks to a youtube, the Online API interface manual versus the Enterprise one, and a lot of trial and error -- 

Survey 123 Sends update -- 

   WebHook fires API -- 

       API Queries Feature Layer where 1=1 & ObjectId = FID & outFields= a, b, c, d 

           API Interfaces with Camera AI to Reset it's Analytics where xid = c. 

Done !  

0 Kudos