Select to view content in your preferred language

How to use relationship info to find feature layers in web map service?

2245
5
03-16-2017 12:16 PM
NickToscano
Deactivated User

In the docs it says:

" You may add one or more layer items to compose a web map or web scene item. Whenever you perform such an operation, you establish a relationship between the items."

I take this to mean that each web map should have a relationship to any layers that have been added to it.

However it seems that if I try to check a map that has a single feature layer, and a publicly hosted basemap I always get the following error for both dependent_to() and dependent_upon() methods:

Unable to get dependents to: 2f1071ac3228427289a6e03d2b625995 Unable to retrieve item dependents.

When I try 

webmap_item.related_items('Map2FeatureCollection', 'forward')

It returns an empty array/list.

What are the limitations of these methods? Do they not work if any of the layers are hosted on a public ArcGIS Server? How about an ArcGIS Server that has security setup?

I tried dependent_to on several feature layers and also received the same error.

5 Replies
SethLewis1
Frequent Contributor

I'm also running into this error message when attempting to map out relationship between portal items, in this case a web map and a layers in the map.

zoningItem.related_items('Map2FeatureCollection', 'forward')

returns an empty array

While running the dependent_upon or dependent_to methods returns:

Unable to get dependencies for item: item#
Unable to retrieve item dependencies.
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-3-2b1d726173d1> in <module>()
----> 1 zoningItem.dependent_upon()

/opt/conda/lib/python3.5/site-packages/arcgis/gis.py in dependent_upon(self)
   2993     def dependent_upon(self):
   2994         """ Returns items and urls, etc that this items depends upon  """
-> 2995         return self._portal.get_item_dependencies(self.itemid)
   2996 
   2997     def dependent_to(self):

/opt/conda/lib/python3.5/site-packages/arcgis/_impl/portalpy.py in get_item_dependencies(self, itemid)
   1124 
   1125     def get_item_dependencies(self, itemid):
-> 1126         return self.con.post('content/items/' + itemid + '/dependencies', self._postdata())
   1127 
   1128     def get_item_dependents_to(self, itemid):

/opt/conda/lib/python3.5/site-packages/arcgis/_impl/connection.py in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token, verify_cert, token)
    954                 elif errorcode == 498:
    955                     raise RuntimeError('Invalid token')
--> 956                 self._handle_json_error(resp_json['error'], errorcode)
    957                 return None
    958         except AttributeError:

/opt/conda/lib/python3.5/site-packages/arcgis/_impl/connection.py in _handle_json_error(self, error, errorcode)
    974 
    975         errormessage = errormessage + "\n(Error Code: " + str(errorcode) +")"
--> 976         raise RuntimeError(errormessage)
    977 
    978 class _StrictURLopener(request.FancyURLopener):

RuntimeError: Unable to get dependencies for item: item#
Unable to retrieve item dependencies.
(Error Code: 500)
0 Kudos
SethLewis1
Frequent Contributor

Bumping this to see if anyone has developed a solution when facing this issue.

0 Kudos
by Anonymous User
Not applicable

Was this ever resolved?

0 Kudos
SethLewis1
Frequent Contributor

I spoke with an ESRI staffer at the UC last summer and he clarified that item relationships must be declared for each item in the portal. I think that would explain the errors mentioned above. I thought that behind the scenes ESRI was graphing the item dependencies and exposing them via the relationship method but that appears to not be the case.

RobertWeber
Regular Contributor

They make very little mention of needing to establish these relationships.  It is implied in the documentation that for Web Map Items in particular it is done in the background.  I only get empty results on any of the three methods.