<?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 ARCGIS python api append new record in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-python-api-append-new-record/m-p/1254741#M8342</link>
    <description>&lt;P&gt;I am trying to insert a python dict record to the hosted online service.&lt;BR /&gt;I am getting the following error:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py", line 2824, in edit_features&lt;BR /&gt;if isinstance(adds[0], dict):&lt;BR /&gt;KeyError: 0&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;My dict is:&lt;BR /&gt;{'OBJECTID': 21641, 'Shape': (689718.442176355, 15309636.152327772), 'ANCILLARYROLE': 0, 'ENABLED': 1, 'CREATIONUSER': 'U437198', 'DATECREATED': datetime.datetime(2023, 1, 11, 0, 0), 'DATEMODIFIED': None, 'LASTUSER': None, 'SUBTYPECD': 1, 'OWNER': 'NYSEG', 'WORKORDERID': '801000483026', 'PROJECTNUMBER': None, 'PROPERTYUNITCODE': None, 'WORKMANAGEMENTSYSTEMCODE': None, 'GASTRACEWEIGHT': 541589504, 'SYMBOLROTATION': 88.94467079, 'DIVISION': 'DANS', 'FACILITYID': '61020001', 'EQUIPMENTID': None, 'COMMENTS': None, 'INSERVICEDATE': None, 'MATERIAL': 'PL', 'VALVEDIAMETER': '4', 'VALVETYPE': 'BAL', 'VALVEUSE': 'ISO', 'ANSIPRESSURERATING': None, 'BONDEDINDICATOR': 'N', 'CLOCKWISETOCLOSE': 'C', 'DEPTH': None, 'DEPTHTONUT': None, 'EMERISOLATIONSYSSTATUS': None, 'GASPRESSURESYSTEMSTATUS': None, 'GASSYSTEMSTATUS': None, 'GROUNDLEVELINDICATOR': None, 'INSULATEDINDICATOR': None, 'NORMALPOSITION': 1, 'PRESENTPOSITION': 1, 'OPERATINGCLASSIFICATION': 'NC', 'LOCATIONDESCRIPTION': None, 'DIMENSIONTIE1': None, 'DIMENSIONTIE2': None, 'MANUFACTURER': None, 'MODEL': None, 'EMERISOLATIONSYSOBJECTID': None, 'GASPRESSURESYSTEMOBJECTID': 830, 'GASSYSTEMOBJECTID': 34, 'SAP_FUNCTIONALLOCATION': None, 'SAP_EQUIPMENTNUMBER': None, 'CIVILDIVISION': None, 'LEGACYID': None, 'INSTALLATIONDATE': datetime.datetime(2022, 12, 6, 0, 0), 'TURNSTOCLOSE': 0.25, 'GLOBALID': '{B10CFD9F-2DB7-40C2-B708-E222222A0AED}', 'OPERATINGSTATE': 'ACTIVE', 'CUSTOMERCOUNT': None, 'CUSTOMERCOUNTDATE': None, 'MAINTENANCE_JOB': 'N', 'CPSYSTEMSTATUS': None, 'DIMENSIONTIE3': None, 'ELEVATION': None, 'ELECTRONICMARKERS': None, 'FLOC_ID': None}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MY code is :&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcgis.features import FeatureLayer&lt;BR /&gt;lyr_url = '&lt;A href="https://services6.arcgis.com/A1NU60yx0I8XSDFS/arcgis/rest/services/ValvesTest/FeatureServer/0" target="_blank" rel="noopener"&gt;https://services6.arcgis.com/A1NU60yx0I8XSDFS/arcgis/rest/services/ValvesTest/FeatureServer/0&lt;/A&gt;'&lt;/P&gt;&lt;P&gt;layer = FeatureLayer(lyr_url)&lt;BR /&gt;feature_count = layer.query(return_count_only=True)&lt;BR /&gt;print("Feature Count: ", feature_count)&lt;BR /&gt;layer.manager.truncate()&lt;BR /&gt;feature_count = layer.query(return_count_only=True)&lt;BR /&gt;print("Now Feature Count: ", feature_count)&lt;/P&gt;&lt;P&gt;fc = "E:\\ABC\\gaspopups.gdb\\DistributionGasValve"&lt;/P&gt;&lt;P&gt;feature = None&lt;BR /&gt;cursor = arcpy.da.SearchCursor(fc, ["*"])&lt;BR /&gt;row = next(cursor)&lt;BR /&gt;feature = {field: value for field, value in zip(cursor.fields, row)}&lt;BR /&gt;layer.edit_features(adds=feature)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to go about it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Feb 2023 07:46:32 GMT</pubDate>
    <dc:creator>Rahul_Pandia</dc:creator>
    <dc:date>2023-02-03T07:46:32Z</dc:date>
    <item>
      <title>ARCGIS python api append new record</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-python-api-append-new-record/m-p/1254741#M8342</link>
      <description>&lt;P&gt;I am trying to insert a python dict record to the hosted online service.&lt;BR /&gt;I am getting the following error:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py", line 2824, in edit_features&lt;BR /&gt;if isinstance(adds[0], dict):&lt;BR /&gt;KeyError: 0&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;My dict is:&lt;BR /&gt;{'OBJECTID': 21641, 'Shape': (689718.442176355, 15309636.152327772), 'ANCILLARYROLE': 0, 'ENABLED': 1, 'CREATIONUSER': 'U437198', 'DATECREATED': datetime.datetime(2023, 1, 11, 0, 0), 'DATEMODIFIED': None, 'LASTUSER': None, 'SUBTYPECD': 1, 'OWNER': 'NYSEG', 'WORKORDERID': '801000483026', 'PROJECTNUMBER': None, 'PROPERTYUNITCODE': None, 'WORKMANAGEMENTSYSTEMCODE': None, 'GASTRACEWEIGHT': 541589504, 'SYMBOLROTATION': 88.94467079, 'DIVISION': 'DANS', 'FACILITYID': '61020001', 'EQUIPMENTID': None, 'COMMENTS': None, 'INSERVICEDATE': None, 'MATERIAL': 'PL', 'VALVEDIAMETER': '4', 'VALVETYPE': 'BAL', 'VALVEUSE': 'ISO', 'ANSIPRESSURERATING': None, 'BONDEDINDICATOR': 'N', 'CLOCKWISETOCLOSE': 'C', 'DEPTH': None, 'DEPTHTONUT': None, 'EMERISOLATIONSYSSTATUS': None, 'GASPRESSURESYSTEMSTATUS': None, 'GASSYSTEMSTATUS': None, 'GROUNDLEVELINDICATOR': None, 'INSULATEDINDICATOR': None, 'NORMALPOSITION': 1, 'PRESENTPOSITION': 1, 'OPERATINGCLASSIFICATION': 'NC', 'LOCATIONDESCRIPTION': None, 'DIMENSIONTIE1': None, 'DIMENSIONTIE2': None, 'MANUFACTURER': None, 'MODEL': None, 'EMERISOLATIONSYSOBJECTID': None, 'GASPRESSURESYSTEMOBJECTID': 830, 'GASSYSTEMOBJECTID': 34, 'SAP_FUNCTIONALLOCATION': None, 'SAP_EQUIPMENTNUMBER': None, 'CIVILDIVISION': None, 'LEGACYID': None, 'INSTALLATIONDATE': datetime.datetime(2022, 12, 6, 0, 0), 'TURNSTOCLOSE': 0.25, 'GLOBALID': '{B10CFD9F-2DB7-40C2-B708-E222222A0AED}', 'OPERATINGSTATE': 'ACTIVE', 'CUSTOMERCOUNT': None, 'CUSTOMERCOUNTDATE': None, 'MAINTENANCE_JOB': 'N', 'CPSYSTEMSTATUS': None, 'DIMENSIONTIE3': None, 'ELEVATION': None, 'ELECTRONICMARKERS': None, 'FLOC_ID': None}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MY code is :&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcgis.features import FeatureLayer&lt;BR /&gt;lyr_url = '&lt;A href="https://services6.arcgis.com/A1NU60yx0I8XSDFS/arcgis/rest/services/ValvesTest/FeatureServer/0" target="_blank" rel="noopener"&gt;https://services6.arcgis.com/A1NU60yx0I8XSDFS/arcgis/rest/services/ValvesTest/FeatureServer/0&lt;/A&gt;'&lt;/P&gt;&lt;P&gt;layer = FeatureLayer(lyr_url)&lt;BR /&gt;feature_count = layer.query(return_count_only=True)&lt;BR /&gt;print("Feature Count: ", feature_count)&lt;BR /&gt;layer.manager.truncate()&lt;BR /&gt;feature_count = layer.query(return_count_only=True)&lt;BR /&gt;print("Now Feature Count: ", feature_count)&lt;/P&gt;&lt;P&gt;fc = "E:\\ABC\\gaspopups.gdb\\DistributionGasValve"&lt;/P&gt;&lt;P&gt;feature = None&lt;BR /&gt;cursor = arcpy.da.SearchCursor(fc, ["*"])&lt;BR /&gt;row = next(cursor)&lt;BR /&gt;feature = {field: value for field, value in zip(cursor.fields, row)}&lt;BR /&gt;layer.edit_features(adds=feature)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to go about it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 07:46:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-python-api-append-new-record/m-p/1254741#M8342</guid>
      <dc:creator>Rahul_Pandia</dc:creator>
      <dc:date>2023-02-03T07:46:32Z</dc:date>
    </item>
  </channel>
</rss>

