<?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: ArcGIS API for Python : Error while publishing content in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-api-for-python-error-while-publishing/m-p/1310760#M68220</link>
    <description>&lt;P&gt;It means that your return from the content.add(...) is None.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;contentManager.add(csv_properties)&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeffK_0-1690026327114.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/76034i9F015952FEE9B5C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeffK_0-1690026327114.png" alt="JeffK_0-1690026327114.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Something is not set correctly and it's not adding so when it gets to the print, it cant subscript None to str.&lt;/P&gt;</description>
    <pubDate>Sat, 22 Jul 2023 11:59:54 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2023-07-22T11:59:54Z</dc:date>
    <item>
      <title>ArcGIS API for Python : Error while publishing content</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-api-for-python-error-while-publishing/m-p/1310356#M68216</link>
      <description>&lt;DIV class=""&gt;Dear Team,&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;I am trying to implement the ArcGIS API for python where in the code im trying to connect to a developer account using an API key, ready a csv file, import into a dataframe and then upload the content as a feature layer.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;I have written the code as said in the tutorial. However, it returns an error&amp;nbsp;"&lt;STRONG&gt;'NoneType' object is not subscriptable&lt;/STRONG&gt;" at the line &lt;STRONG&gt;&lt;SPAN class=""&gt;csv_item&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;contentManager&lt;/SPAN&gt;&lt;SPAN class=""&gt;.add(&lt;/SPAN&gt;&lt;SPAN class=""&gt;csv_properties&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;)&lt;/STRONG&gt; as per my understanding&lt;/SPAN&gt;.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;STRONG&gt;&lt;U&gt;Please find below the code snippet: (Portion that errs out is highlighted in yellow)&lt;/U&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def upload_csv(request):
    try:

        csv_filename = request.GET.get("csv_filename","")
        ARC_GIS_API_KEY = apps.get_app_config('arcgis_bridge').ARC_GIS_API_KEY
        if csv_filename:
            if ARC_GIS_API_KEY:

                    gis = GIS(api_key=ARC_GIS_API_KEY)

                    if gis:
                        dir_path = os.path.dirname(os.path.realpath(__file__))
                        print("dir_path :: ", dir_path)
                        data_path = os.path.join(dir_path, "..\input_data")
                        print("data_path :: ", data_path)
                        csv_path = os.path.join(data_path, csv_filename)
                        print("csv_path :: ", csv_path)
                        ports_df = pandas.read_csv(csv_path)
                        # print("ports_df :: ", ports_df)
                        ports_fc = gis.content.import_data(ports_df)
                        print("ports_fc :: ", ports_fc)
                        # ports_fc_dict = dict(ports_fc.properties)
                        ports_fc_dict = dict(ports_fc.layer)
                        # print("ports_fc_dict :: ", ports_fc_dict)
                        ports_json = json.dumps({"featureCollection": {"layers": [ports_fc_dict]}})
                        # print("ports_json :: ", ports_json)
                        csv_properties = {
                            'title': 'test file',
                            'description': 'attempting content upload from API',
                            'tags': 'arcgis, python, testing, csv, importing',
                            'text': ports_json,
                            'type': 'Feature Collection'
                        }
                        try:
                            contentManager = gis.content
                            print("contentManager :: ", contentManager)
                            csv_item = contentManager.add(csv_properties)
                            print("csv_item :: ", csv_item)
                            csv_item_publish = csv_item.publish()
                            print("csv_item_publish :: ", csv_item_publish)
                        except Exception as e:
                            print("csv_item ERROR :: ", str(e))
                            return JsonResponse({"error": True, "message":str(e)})
                        return JsonResponse({"error": False, "message":"CSV Uploaded Successfully.","csv_item_publish":csv_item_publish})
                    else:
                        return JsonResponse({"error": True, "message":"ARC GIS API CONNECTION COULD NOT BE OBTAINED.","csv_item_publish":{}})
            else:
                return JsonResponse({"error": True, "message":"ARC GIS API KEY IS MISSING.","csv_item_publish":{}})
        else:
            return JsonResponse({"error": True, "message":"CSV FILE NAME IS MISSING.","csv_item_publish":{}})

    except Exception as e:
        return JsonResponse({"error": True, "message":str(e), "csv_item_publish":''})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;STRONG&gt;&lt;U&gt;Terminal Output:&lt;/U&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;[21/Jul/2023 10:07:50] "GET /arcgis_bridge/uploadCSV?csv_filename=file1.CSV HTTP/1.1" 200 68
dir_path ::  C:\Users\aksha\Projects\arc_gis\sree_app\arcgis_bridge
data_path ::  C:\Users\aksha\Projects\arc_gis\sree_app\arcgis_bridge\..\input_data
csv_path ::  C:\Users\aksha\Projects\arc_gis\sree_app\arcgis_bridge\..\input_data\file1.CSV
ports_fc ::  &amp;lt;FeatureCollection&amp;gt;
contentManager ::  &amp;lt;arcgis.gis.ContentManager object at 0x0000023BC9E03070&amp;gt;
csv_item ERROR ::  'NoneType' object is not subscriptable&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;Looking forward to any support on this regard.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Jul 2023 05:24:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-api-for-python-error-while-publishing/m-p/1310356#M68216</guid>
      <dc:creator>AmritaJayakumar</dc:creator>
      <dc:date>2023-07-21T05:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS API for Python : Error while publishing content</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-api-for-python-error-while-publishing/m-p/1310760#M68220</link>
      <description>&lt;P&gt;It means that your return from the content.add(...) is None.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;contentManager.add(csv_properties)&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeffK_0-1690026327114.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/76034i9F015952FEE9B5C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeffK_0-1690026327114.png" alt="JeffK_0-1690026327114.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Something is not set correctly and it's not adding so when it gets to the print, it cant subscript None to str.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jul 2023 11:59:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-api-for-python-error-while-publishing/m-p/1310760#M68220</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-07-22T11:59:54Z</dc:date>
    </item>
  </channel>
</rss>

