Skip to main content

Hi All,

 

I have been getting my head around FME Server and Webhooks with Survey123 data collection, and I am loving it!

 

I can competently capture data via a Survey123 form, then trigger some FME automation to manipulate the data and email a specific user results dependant on what was captured in the Survey123 form. This is working well.

 

I would now love to take this to the next level by using the formal Survey123 Report rest API. So ideally I want to get a copy of the Survey123 report PDF that is generated each time the webhook is triggered, and email this PDF to particular people.

 

I have been searching this forum and I do not see any tutorials or any mention of working with the Survey123 Report API itself.

 

Has anyone had any experience with setting up an automation that works with the ESRI Survey123 Report creation API, that they would be willing to share with me?

 

note: I know with FME I can do pretty much everything the Survey123 report generator can do, in the long run with the dozens and dozens of surveys we have already published, I think the API would save us time in the long run.

 

@nduncanacc​ 

Hi @benvk​ ! Glad you're getting some good use out of the Survey123 webhooks with FME Server. I haven't used the Survey123 Report REST API myself, but I'd like to look into it more at some point. So, I don't have a workspace or automation to share yet. But, looking at the Esri documentation and using the general steps they lay out, I would:

 

  1. Submit the report request using the createReport/submitJob endpoint
    1. Use the HTTPCaller with an ArcGIS Online named Web Connection in place of a token parameter
    2. Request URL: https://survey123.arcgis.com/api/featureReport/createReport/submitJob
    3. HTTP Method: POST
    4. Query String Parameters:
      1. featurelayerURL: you can get this from your survey's feature layer in AGOL
      2. queryParameters: {"where": "objectIds"=@Value(objectid)} <- assuming you have an objectid attribute in your workspace for the survey response feature you want to report on; you should from your webhook data
      3. templateItemId: after you create your template in Survey123, it should be visible in AGOL where you can get the ID for it from the template item's URL (there are likely other ways too)
      4. outputFormat: pdf
      5. f: JSON
    5. This will submit a job and return a job ID (you will need to parse it from the HTTPCaller's response body JSON)
  2. Create a custom embedded transformer with a loop that recursively calls the Jobs API (jobs/<your job ID>)
    1. Again, using an HTTPCaller
    2. Keep looping until you get a status returned of esriJobSucceeded, esriJobPartialSucceeded or esriJobFailed (will need to parse jobStatus from the JSON)
    3. Download and embed the ArcGISOnlineWebhookDataGetter transformer for an example of this pattern; it is used for AGOL webhooks, which are quite different from Survey123 webhooks, but have a similar flow to these Report APIs
  3. According to Esri, from there: if the jobStatus is either esriJobSucceeded or esriJobPartialSucceeded, you can then download the output files. Either a URL to the file will be present in the resultInfo property for each file, or an identifier which corresponds to the itemID of the file in ArcGIS Online.

 

This one is a bit tricky; hope this helps. Good luck!


Hello @benvk​ . I followed Matt's suggestion and got it to work. Thanks Matt for the suggestions. I added a few more parameters such as outputReportName and surveyItemId and I used the multi part/format to add all the parameters. After looping to check for the job status and getting the status esriJobSucceeded , I grabbed the itemID from the response and downloaded the file locally using an HTTP Caller and the request url I used was https://orgname/sharing/rest/content/items/itemID/data.

 

Hope this helps.


Reply