Survey123 Python Module Feature Report Names

354
1
12-05-2020 11:06 AM
DrewNemecek
New Contributor II

I am using Survey123 version 3.9 and the ArcGIS API for Python. I am successfully downloading reports, but I seem to have no control over the report file name. The test file name I am using is "Feature Report Title", but the file name of the report ouptut is "SurveyNameOIDXXXYYYYMMDDxxxxxx". When I don't specify the URL of my organization's ArcGISOnline account for GIS(), I see "Feature Report Title" in the survey's Report --> Recent tasks pane on Survey123 for a failed report download, but the report failed to download, and I get this message, "An error occurred when uploading result files to Portal for ArcGIS. 498. Invalid token.". Can I control the file name of the generate_report() outputs? I read this, https://community.esri.com/t5/arcgis-survey123-questions/survey123-report-feature-how-to-change-the-..., which indicates that in early 2019, controlling file names is not an option.

Here is my code:

 username = 'myname_organization'

password = 'password'

template = 1

utc_offset = '-07:00'

gis = GIS("https://organization.maps.arcgis.com", username=username, password=password)

sm = arcgis.apps.survey123.SurveyManager(gis)

survey_id = 'some unique identifier'

where_clause = 'objectid=someOID'

report_title = "Feature Report Title"

templates = survey.report_templates

survey.generate_report(templates[template], where_clause, utc_offset, report_title)

for x in survey.reports:

if survey_id in x.description:

data_item = gis.content.get(x.id)

data_item.download(save_path=r'DownloadFolderPath')

1 Reply
by Anonymous User
Not applicable

I'm experiencing the same 498 Invalid token error message.  My script was working until a recent problem occurred when trying to run Feature Reports in Survey 123 Web app (https://community.esri.com/t5/arcgis-survey123-questions/item-specified-by-surveyitemid-does-not-exi...). For about a week some users we were not able to run Feature Reports in the S123 Web app.  Within a week ESRI released a fix that corrected the issue however since then I have not been able to use the ArcGIS API for Python.

I also would like the ability to control the report file name.  I would use some of the survey results to specify a report name (i.e. Job number, user name, etc).