<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to handle and troubleshoot internal/helper function failures in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-handle-and-troubleshoot-internal-helper/m-p/1337362#M9136</link>
    <description>&lt;P&gt;I am fairly new to python and need recommendations on how to handle internal/helper function failures.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script that that imports a list of jurisdictions, then iterates through that list and creates a view, map, and experience builder application tailored to that jurisdiction. It's working more or less flawlessly but is routinely failing on the third iteration. And the failure happens due to an error with the arcgis\features\managers.py helper.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;KeyError                                  Traceback (most recent call last)
c:\Users\user\path_to_project\script.py in &amp;lt;cell line: 40&amp;gt;()
     224 for j in jList: #changed 'jurisdiction' to 'j'
     225     #*Create Views
---&amp;gt; 226     jView = masterLayer.manager.create_view(name = j + '_view',      spatial_reference = sr, tags = tagsText, capabilities = "Create,Query,Update,Delete,Editing,ChangeTracking")
     227     jView.move(folder = folder)
     228     jViewFLC = arcgis.features.FeatureLayerCollection.fromitem(jView)

c:\Users\user\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\managers.py in create_view(self, name, spatial_reference, extent, allow_schema_changes, updateable, capabilities, view_layers, view_tables, description, tags, snippet, overwrite, set_item_id, preserve_layer_ids)
   2006             params["description"] = description
   2007         res = gis._con.post(path=url, postdata=params)
-&amp;gt; 2008         view = content.get(res["itemId"])
   2009         fs_view = FeatureLayerCollection(url=view.url, gis=gis)
   2010         add_def = {"layers": [], "tables": []}

KeyError: 'itemId'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The loop runs all the way through the first two items in the list and then fails on the third. It was running all the way through two days ago and nothing has much changed (I made some tweaks to other areas of the script, but don't think it would affect it). How do I isolate the error?&lt;/P&gt;</description>
    <pubDate>Thu, 12 Oct 2023 16:29:45 GMT</pubDate>
    <dc:creator>SFM_TravisBott</dc:creator>
    <dc:date>2023-10-12T16:29:45Z</dc:date>
    <item>
      <title>How to handle and troubleshoot internal/helper function failures</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-handle-and-troubleshoot-internal-helper/m-p/1337362#M9136</link>
      <description>&lt;P&gt;I am fairly new to python and need recommendations on how to handle internal/helper function failures.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script that that imports a list of jurisdictions, then iterates through that list and creates a view, map, and experience builder application tailored to that jurisdiction. It's working more or less flawlessly but is routinely failing on the third iteration. And the failure happens due to an error with the arcgis\features\managers.py helper.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;KeyError                                  Traceback (most recent call last)
c:\Users\user\path_to_project\script.py in &amp;lt;cell line: 40&amp;gt;()
     224 for j in jList: #changed 'jurisdiction' to 'j'
     225     #*Create Views
---&amp;gt; 226     jView = masterLayer.manager.create_view(name = j + '_view',      spatial_reference = sr, tags = tagsText, capabilities = "Create,Query,Update,Delete,Editing,ChangeTracking")
     227     jView.move(folder = folder)
     228     jViewFLC = arcgis.features.FeatureLayerCollection.fromitem(jView)

c:\Users\user\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\managers.py in create_view(self, name, spatial_reference, extent, allow_schema_changes, updateable, capabilities, view_layers, view_tables, description, tags, snippet, overwrite, set_item_id, preserve_layer_ids)
   2006             params["description"] = description
   2007         res = gis._con.post(path=url, postdata=params)
-&amp;gt; 2008         view = content.get(res["itemId"])
   2009         fs_view = FeatureLayerCollection(url=view.url, gis=gis)
   2010         add_def = {"layers": [], "tables": []}

KeyError: 'itemId'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The loop runs all the way through the first two items in the list and then fails on the third. It was running all the way through two days ago and nothing has much changed (I made some tweaks to other areas of the script, but don't think it would affect it). How do I isolate the error?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 16:29:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-handle-and-troubleshoot-internal-helper/m-p/1337362#M9136</guid>
      <dc:creator>SFM_TravisBott</dc:creator>
      <dc:date>2023-10-12T16:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle and troubleshoot internal/helper function failures</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-handle-and-troubleshoot-internal-helper/m-p/1405611#M9838</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/106199"&gt;@SFM_TravisBott&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to look into try/except for error handling with Python. This will allow you to handle the error gracefully. You are getting a KeyError which means the "itemId" key was not found in your dictionary. With exceptions handling you can tell the script what to do when this error is encountered.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 08:57:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-handle-and-troubleshoot-internal-helper/m-p/1405611#M9838</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2024-04-04T08:57:39Z</dc:date>
    </item>
  </channel>
</rss>

