What is the best method to automate the download Survey123 data?

892
6
Jump to solution
12-13-2019 02:41 AM
JimPhillips
New Contributor II

We have a number of Survey123 forms and I'm looking at the best way to back them up/download them. I have experimented with Microsoft Flow webhooks and this looks like one good method to hold a backup, albeit quite fiddly with the initial set up (where there are a lot of fields in a survey). I'm particularly looking to script the download of all of the surveys and hold timestamped geodatabase backups. I have found the following script at the end of this url which looks fit for purpose:

View your results—Survey123 for ArcGIS | Documentation 

However, whenever I try to run this script I get the following error:

...Starting
...Authenticating against your Portal
...Exporting data

Traceback (most recent call last):
File "C:\DownloadSurvey123Data.py", line 78, in <module>
exportItemId = export_data['exportItemId']
KeyError: 'exportItemId'

No matter what itemid I use, I get the same error so I know that this isn't related to one particular feature class. Any help with this would be massively appreciated! I'm drawing a blank trying to get it to run.

Thanks in advance!

1 Solution

Accepted Solutions
JimPhillips
New Contributor II

Hi Jim,

Thanks for your help, it turned out to be that I had put my username is all lower-case... I didn't realise it was case-sensitive! Quite simple fail, but glad to have the script working now.

Thanks again,

Luke

View solution in original post

6 Replies
Jim-Moore
Esri Regular Contributor

Hi Jim

Just to confirm, are you entering the item ID of the feature layer that contains the survey data (as opposed to the survey's Form item)? And is this feature layer owned by the user whose credentials you've entered in the script?

Best,

Jim

0 Kudos
JimPhillips
New Contributor II

Hi Jim,

Thanks for the reply, unfortunately it's yes to both of those - I've tried it with many different item IDs too just to be sure it wasn't a specific survey but I get that error regardless. Very frustrating as this tool looks ideal! Is this a documented problem?

Many thanks,

Luke

0 Kudos
Jim-Moore
Esri Regular Contributor

Hi Luke

I've just tested the script and was able to successfully download the data for a survey I own. I have ArcGIS Desktop 10.7 installed with Python 2.7.15. Here are the parameters I used:

And here's the log:

The script also ran successfully for a feature layer on a 10.7.1 Portal.

The KeyError suggests that in the list of item IDs returned there's no match for the featureService_ID parameter. If I enter a dummy item ID for this parameter I receive the same error you're seeing.

Do your parameters look similar to the above?

Best,

Jim

0 Kudos
JimPhillips
New Contributor II

Hi Jim,

Thanks for your help, it turned out to be that I had put my username is all lower-case... I didn't realise it was case-sensitive! Quite simple fail, but glad to have the script working now.

Thanks again,

Luke

Jim-Moore
Esri Regular Contributor

Cheers Luke, great to hear it's working now.

0 Kudos
jfiacco
New Contributor II

Hi,

Does anyone have access to the script that is referenced in the original post? I've seen a few posts that reference this same URL but the script is no where to be found. Am I missing something? I'm wondering if it has been moved to a new location or removed all together. Any information would be greatly appreciated.

Thanks!!

0 Kudos