I'm having an issue with appending to a hosted feature service with a shapefile using the .append() method. I keep getting a very non-descriptive error which is:
ERROR:arcgis._impl.connection:Object reference not set to an instance of an object.
Traceback (most recent call last):
File "C:/Users/c-jermoore/Desktop/Farmland_Preservation_Scripts/DO_NOT_DELETE/AGOL_Clip_Soils_Layer_No_GUI/AGOL_Clip_Soils_Layer.py", line 460, in <module>
upload_format="shapefile")
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py", line 1134, in append
sres = self._con.get(path=surl, params={'f' : 'json'})
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\connection.py", line 898, in get
self._handle_json_error(resp_json['error'], errorcode)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\connection.py", line 1198, in _handle_json_error
raise RuntimeError(errormessage)
RuntimeError: Object reference not set to an instance of an object.
(Error Code: 400)
I'm not exactly sure what this means. I had a suspicion that it might be due to fields not matching, which some don't but I'm mapping them in the parameters for the method. So now I'm wondering if maybe I'm not calling the FeatureLayer item correctly.
Has anyone ever run into this before?
Here is the block of code giving me issues:
getclippedSoilsSHPItemID <SPAN class="operator token">=</SPAN> agolLogin<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>findClippedSoilsSHPList<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>getclippedSoilsSHPItemID<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN>
layerToAppend <SPAN class="operator token">=</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis<SPAN class="punctuation token">.</SPAN>Item<SPAN class="punctuation token">(</SPAN>gis<SPAN class="operator token">=</SPAN>agolLogin<SPAN class="punctuation token">,</SPAN> itemid<SPAN class="operator token">=</SPAN><SPAN class="string token">"60820364b71743c49822a60da1e85492"</SPAN><SPAN class="punctuation token">)</SPAN>
testAppendSoilsLayer <SPAN class="operator token">=</SPAN> layerToAppend<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>testAppendSoilsLayer<SPAN class="punctuation token">)</SPAN>
testAppendSoilsLayer<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>item_id<SPAN class="operator token">=</SPAN>getclippedSoilsSHPItemID<SPAN class="punctuation token">,</SPAN>
field_mappings<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"AREASYMBOL"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"source"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"AREASYMBOL"</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">{</SPAN><SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"SPATIALVER"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"source"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"SPATIALVER"</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">{</SPAN><SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"MUSYM"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"source"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"MUSYM"</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">{</SPAN><SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"MUKEY"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"source"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"MUKEY"</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">{</SPAN><SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Mapunit_Name"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"source"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Mapunit_Na"</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">{</SPAN><SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Non_Irrigated_Capability_Class___Dominant_Condition"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"source"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Non_Irriga"</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>
upload_format<SPAN class="operator token">=</SPAN><SPAN class="string token">"shapefile"</SPAN><SPAN class="punctuation token">)</SPAN>
logging<SPAN class="punctuation token">.</SPAN>info<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"DONE!"</SPAN><SPAN class="punctuation token">)</SPAN>
exit<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Any help would be greatly appreciated