Python API not showing dependent map layers

2107
10
Jump to solution
07-24-2017 12:52 PM
OliviaDeSimone
Occasional Contributor

I'm trying to use the Python API to see the dependent map layers in some of my organization's web maps.  I am following the "Finding relationships between items: Relationship between web map items" on the ArcGIS API for Python Guide documentation.

I made a pretty standard web map with just two layers in it: one feature layer hosted on my organization's AGO account and one map service coming for my organization's stand-alone server that has been registered as at item on the AGO.

I used pretty similar variables to the documentation when testing (please see attached image).  However, the "dependent.upon()" method does not return any results.  According the documentation, it should be returning at least the basemap which is a standard esri basemap and the same one that is returned by the method in the help documentation. Am I missing something?

1 Solution

Accepted Solutions
AtmaMani
Esri Contributor

Olivia, this capability (item dependencies) is not yet available on ArcGIS Online. Currently it is available only with an ArcGIS Enterprise.

View solution in original post

10 Replies
AtmaMani
Esri Contributor

Olivia, this capability (item dependencies) is not yet available on ArcGIS Online. Currently it is available only with an ArcGIS Enterprise.

View solution in original post

KimHerkewitz
New Contributor

The fact that this capability is only available in Enterprise would be very helpful to know. If this is clearly stated in the Dev. Summit videos, the hours spent trouble-shooting why the API is not performing as expected could be avoided. Is there a time frame for integrating item dependency with AGOL?

HNoakes
Esri Contributor

AMani-esristaff Can you provide an update on this capability and when it is expected to be available for ArcGIS Online content?

AtmaMani
Esri Contributor

cwhitmore4‌ could you respond to this question on item-item dependency?

MichaelZatorsky
New Contributor III

Does anyone know if this has changed in the last 6 months?  Is support for tracking dependencies in ArcGIS Online on the Python API roadmap?

Trying it today on a test web map, with many layers and used in a web mapping app, it results in zero results for dependent_upon and dependent_to, e,g:

test_wm_id = "1b943029bfff44ca9128bbf59a3c984n"
wm_item = gis.content.get(test_wm_id)
wm_item.dependent_upon()‍‍‍‍‍‍

Returns:

{'list': [], 'nextStart': -1, 'num': 0, 'start': 1, 'total': 0}‍

While

wm_item.dependent_to()

Returns
{'list': [], 'nextStart': -1, 'num': 0, 'start': 1, 'total': 0}

I would expect the web map to be dependent on many hosted feature layers and dependent to at least one web mapping application.

This capability is present in the GEO-Jobe pro tools... 'must be possible somehow?
Viewing Item Dependencies in Admin Tools for ArcGIS℠ Online - YouTube 

BrianKaplan
Occasional Contributor

Its November 27, 2018 and I have found the same in that this Python API for dependent on and upon still does not work with ArcGIS Online but only Enterprise.

RichardStokes1
New Contributor

9th January 2019 checking in, Atma Mani‌ any updates or etas?

At the very least, this note in the documentation needs to be changed:

"NOTE: The Relationship Type functionality is currently evolving within Enterprise and ArcGIS Online implementations. Some items do not currently return all relationships they have between other items."

If the functionality isn't there yet, any reference to AGOL should be removed, it might save a bunch of people time and effort.

deleted-user-Ey5hWtkij2kJ
New Contributor

Hi Richard,

Getting dependencies on Web Maps is still not supported i think in ArcGIS Online.

Instead, i tried using the Item data of a ArcGIS online item and I was able to get the dependent layer details. 

Thought might be useful to others.

from arcgis import gis
from json import loads


def get_map_item_dependencies(source_portal, item, folder, user):
# We are using this script only for 'Web Map' , as this is the problem item for ArcGIS Online
if item.type == 'Web Map':
# Get the item's data in JSON format
item_data = item.get_data(False)
data = dict(loads(item_data))
# Just go through the Operational Layers, as they are mainly the dependent items
for layer_item in data['operationalLayers']:
layer_itemInfo = source_portal.content.get(layer_item['itemId']) if 'itemId' in layer_item else ''
print("; ".join((item.title,
user.fullName,
folder,
item.itemid,
item.type,
layer_item['title'],
layer_itemInfo.owner if layer_itemInfo and 'owner' in layer_itemInfo else '',
layer_item['layerType'],
layer_item['itemId'] if 'itemId' in layer_item else '',
layer_item['url'] if 'url' in layer_item else '')) + '\n')


def main():
source = gis.GIS("https://arcgis.maps.arcgis.com", username='', password='')
# Get the user and their items
userName = ''
user = source.users.get(userName)
user_content = user.items(max_items=1000)

# Get item ids from root folder first
for item in user_content:
get_map_item_dependencies(source, item, 'Root Folder', user)

# Get item ids from each of the folders next
folders = user.folders
for folder in folders:
folder_items = user.items(folder=folder['title'])
for item in folder_items:
get_map_item_dependencies(source, item, folder['title'], user)
AndresCastillo
MVP Regular Contributor

As of version 1.8.2 of the ArcGIS Python API, this is not available:

arcgis.gis module — arcgis 1.8.2 documentation 

Reply
0 Kudos