Select to view content in your preferred language

Access non-public results from Survey123 outside of agol environment

1152
10
Jump to solution
07-05-2023 04:26 PM
ChristopheSchnaufer
New Contributor II

First time posting here. I am trying to access Survey123 results that aren't Everyone(public) using the `arcgis` Python package from a machine that does not have ArcGIS installed. Unfortunately, I am only able to access public results in my account (and elsewhere). The end goal is to access data that had been shared with me from another group (and won't be public). The following sample code shows what I've done so far. Any help is appreciated

from arcgis.gis import GIS

# ESRI Survey123 API endpoint
survey123_api_url = 'https://www.arcgis.com'
survey123_username = '<my_username>'
survey123_password = '<my_password>'

# Get a list of non-public Survey123 data
survey_item_id = '88d7e11f82fa44c0a52db4ba435b86ff'
gis = GIS(survey123_api_url, survey123_username, survey123_password)

# Use SurveyManager to see everything available
survey_manager = arcgis.apps.survey123.SurveyManager(gis)
print(survey_manager.surveys) # only contains public items

# Try to get a non-public item
sbi = survey_manager.get(survey_item_id)
print(sbi) # only contains item when it's public

sr = gis.content.search('owner:<my account name>')
print(sr)   # also only contains public items
0 Kudos
10 Replies
ChristopheSchnaufer
New Contributor II

I have a solution in hand! Thanks to @ChristopherCounsell and @alex_mapintel  for all their help

import arcgis
from arcgis.gis import GIS

# ESRI endpoint
esri_url = 'https://www.arcgis.com'
esri_username = '<username>'
esri_password = '<password>'

# Connect to ArcGIS
gis = GIS(esri_url, esri_username, esri_password)

# Search for accessible content
search_results = gis.content.search('owner:<username>')
for one_search in search_results:
    # Find the feature service that you are looking for
    if one_search.type == 'Feature Service':
        # Choose the layer of interest
        feature_layer = one_search.layers[0]
        # Perform a query to get all of the data
        results = feature_layer.query(where='OBJECTId>=0')
        # Process the returned data (printing in this case)
        for data in results.features:
            print(data.as_dict)

 I still am having other issues, but I can not be sure I'm accessing available data

0 Kudos