<?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 Re: Type Error with is_service_name_available in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/type-error-with-is-service-name-available/m-p/1122166#M6870</link>
    <description>&lt;P&gt;Thank you! That worked&lt;/P&gt;</description>
    <pubDate>Thu, 02 Dec 2021 14:08:55 GMT</pubDate>
    <dc:creator>GIS_utahDEM</dc:creator>
    <dc:date>2021-12-02T14:08:55Z</dc:date>
    <item>
      <title>Type Error with is_service_name_available</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/type-error-with-is-service-name-available/m-p/1121896#M6863</link>
      <description>&lt;P&gt;I am having issues using ContentManager.is_service_name_available(). I am using it within a for loop to create view layers to check whether the view layer has already been created (code below). I am getting errors that I don't have a "self" argument, even though I'm pretty sure I do (screenshot of error below). If anyone has insight in how to fix this, or another method of checking whether a layer has already been created, let me know! Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Loop through the regional division to create the views
for index, county in enumerate(counties_munis):
    county_name = counties_munis.features[index].attributes['NAME']
    print(county_name)
    view_name = 'UCIP_' + "_" + county_name + "_View"
    print(view_name)
    # Get the geometry for the regions
    view_geom = counties_munis.features[index].geometry.get('rings')
    name_avail = ContentManager.is_service_name_available(service_name = view_name,service_type = "featureService")
    # Check if view exists
    if  name_avail == True:
        new_view = ucip_locs_flc.manager.create_view(name=view_name)
        # Search for newly created View
        view_search = my_agol.content.search(view_name)[0]
        view_flc = FeatureLayerCollection.fromitem(view_search)

        service_layer = view_flc.layers[0]
        layerTags = [county_name,"UCIP","View Layer"]

        # Populate the update_dict with the geometry and the spatial reference
        update_dict = {"tags":layerTags,"viewLayerDefinition":{"filter":
                                                               {"operator":"esriSpatialRelContains","value":
                                                                {"geometryType":"esriGeometryPolygon","geometry":
                                                                 {"rings": view_geom,
                                                                  "spatialReference":spat_ref}}}}}

        # Update the definition to include the Area of Interest
        service_layer.manager.update_definition(update_dict)
        print("Added ",view_name)
    else:
        print(view_name," Exists")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 20:47:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/type-error-with-is-service-name-available/m-p/1121896#M6863</guid>
      <dc:creator>GIS_utahDEM</dc:creator>
      <dc:date>2021-12-01T20:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Type Error with is_service_name_available</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/type-error-with-is-service-name-available/m-p/1122045#M6866</link>
      <description>&lt;P&gt;Please try it like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis.content.is_service_name_available(....)
# or like this:
cm = ContentManager(&amp;lt;gis_instance&amp;gt;)
cm.is_service_name_available(..)&lt;/LI-CODE&gt;&lt;P&gt;Long answer:&lt;/P&gt;&lt;P&gt;The is_service_name_available() method is an instance method (not static), so you need to call it on an instance. We prefer the first pattern in the example above as it is easier to read&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 03:35:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/type-error-with-is-service-name-available/m-p/1122045#M6866</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-02T03:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Type Error with is_service_name_available</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/type-error-with-is-service-name-available/m-p/1122166#M6870</link>
      <description>&lt;P&gt;Thank you! That worked&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 14:08:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/type-error-with-is-service-name-available/m-p/1122166#M6870</guid>
      <dc:creator>GIS_utahDEM</dc:creator>
      <dc:date>2021-12-02T14:08:55Z</dc:date>
    </item>
  </channel>
</rss>

