<?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: Unexplained behaviour when upserting a hosted feature layer in AGO with UI and API in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1346846#M55729</link>
    <description>&lt;P&gt;Hi &lt;SPAN&gt;StijnSchoutenTh&lt;/SPAN&gt;&lt;SPAN&gt;eGISLord,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm sorry to hear you're experiencing an issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this behaviour also observed when you match on a different field with a unique index that is not the OBJECTID?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2023 19:11:51 GMT</pubDate>
    <dc:creator>timcneil</dc:creator>
    <dc:date>2023-11-07T19:11:51Z</dc:date>
    <item>
      <title>Unexplained behaviour when upserting a hosted feature layer in AGO with UI and API</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1346603#M55722</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm a bit stumped on this one. Especially the fact that the AGO returns zero errors when upserting an hosted feature layer with new/updated features. I'll try to be as thorough as possible:&lt;/P&gt;&lt;P&gt;I have a total of 31058 features I want to upload to a hosted feature layer. These features are split between two files (20027 &amp;amp; 11031 features each) . I'm trying two methods: API (preferred) and via the UI (for testing). With both methods the total nr of features after upserting is less then the 31058 and I have no idea why...&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Step 1:&lt;/P&gt;&lt;P&gt;In the &lt;U&gt;attached&lt;/U&gt; .zip (it is all public data) there is a .json file called 'initial.json'. Im using this as a sort of schema definition for the layer. I'm uploading this to AGO and publishing the layer as hosted feature layer. So far so good&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_0-1699351490235.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85225i5C24878996BA0BD6/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_0-1699351490235.png" alt="StijnSchoutenTheGISLord_0-1699351490235.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_1-1699351522429.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85226i56008A8EB357B5A8/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_1-1699351522429.png" alt="StijnSchoutenTheGISLord_1-1699351522429.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;(single feature)&lt;/P&gt;&lt;P&gt;Step 2a (UI Route):&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the "Update Data" button of the hosted feature layer:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_2-1699351629536.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85227iA910C76AC8E5E705/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_2-1699351629536.png" alt="StijnSchoutenTheGISLord_2-1699351629536.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Uploading "update1.geojson" and setting the identifier as such:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_4-1699351725969.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85229i5D141C56F2938EA8/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_4-1699351725969.png" alt="StijnSchoutenTheGISLord_4-1699351725969.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And letting AGO do the mapping for me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_5-1699351733295.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85230i6C0CE229E584E64A/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_5-1699351733295.png" alt="StijnSchoutenTheGISLord_5-1699351733295.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I click &amp;lt;next&amp;gt; and select the option to update &lt;U&gt;Attributes and Geometries&lt;/U&gt;&lt;/P&gt;&lt;P&gt;AGO will then process the file and mention that the layer has been successfully updated with 11031 new features:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_6-1699351849828.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85232iC373811137AC3805/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_6-1699351849828.png" alt="StijnSchoutenTheGISLord_6-1699351849828.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When i check the data tab it is reading 11032 features! So this is also going well:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_7-1699351905311.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85233iD18CC11710A64D4A/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_7-1699351905311.png" alt="StijnSchoutenTheGISLord_7-1699351905311.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I do the same for "update2.geojson". With also the same success message:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_9-1699352008403.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85235iB98F4E7A86AFB904/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_9-1699352008403.png" alt="StijnSchoutenTheGISLord_9-1699352008403.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So logically the total count should be 31058 right? Wrong:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_10-1699352069809.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85236i43BCD8E2F8D40EB4/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_10-1699352069809.png" alt="StijnSchoutenTheGISLord_10-1699352069809.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've checked that the objectid's are unique and that the geometries are valid. I've checked this with JSON To Features in ArcGIS Pro.&lt;/P&gt;&lt;P&gt;Swapping the order (first update2 then update1) results in a slightly different total amount:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_11-1699352867113.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85237i3096D833FD50AEB4/image-size/large?v=v2&amp;amp;px=999" role="button" title="StijnSchoutenTheGISLord_11-1699352867113.png" alt="StijnSchoutenTheGISLord_11-1699352867113.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As it first fully uploads the first geojson file and then partially uploads the second geojson file. So it seems that the problem is not in the quality of the geojson files but in the &lt;STRONG&gt;order&lt;/STRONG&gt; which seems even stranger to me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 2b (API Route).&lt;BR /&gt;The results are the same when using the Python SDK API&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def upsert_layer(gis_engine: gis.GIS, uploaded_item: str, layer: str):
    search_result = gis_engine.content.search(query=f'title: "{layer}" AND type: "Feature Service"')
    if len(search_result) == 0:
        gis_engine.content.delete_items([uploaded_item])
        raise RuntimeError(f"Layer: {layer} can not be found")
    if len(search_result) &amp;gt; 1:
        gis_engine.content.delete_items([uploaded_item])
        raise RuntimeError(f"More then 1 layer found for layer: {layer}")
    item = gis_engine.content.get(search_result[0].id)
    print(item.layers[0].append(uploaded_item, upload_format='geojson', upsert=True, upsert_matching_field='OBJECTID', rollback=True, return_messages=True))
    time.sleep(2) # trying not to hammer the server
    gis_engine.content.delete_items([uploaded_item])&lt;/LI-CODE&gt;&lt;P&gt;And the result of the print statement is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;(True, {'layerName': 'AE_GEODATA_PRODUCTS_OSM_ZONNEPARKEN_AGO_DEV_points', 'submissionTime': 1699350508877, 'lastUpdatedTime': 1699350520370, 'recordCount': 20027, 'status': 'Completed'})
(True, {'layerName': 'AE_GEODATA_PRODUCTS_OSM_ZONNEPARKEN_AGO_DEV_points', 'submissionTime': 1699350538790, 'lastUpdatedTime': 1699350546083, 'recordCount': 11031, 'status': 'Completed'})&lt;/LI-CODE&gt;&lt;P&gt;Any suggestions or members willing to test this also is greatly appreciated&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 10:33:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1346603#M55722</guid>
      <dc:creator>StijnSchoutenTheGISLord</dc:creator>
      <dc:date>2023-11-07T10:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Unexplained behaviour when upserting a hosted feature layer in AGO with UI and API</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1346846#M55729</link>
      <description>&lt;P&gt;Hi &lt;SPAN&gt;StijnSchoutenTh&lt;/SPAN&gt;&lt;SPAN&gt;eGISLord,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm sorry to hear you're experiencing an issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this behaviour also observed when you match on a different field with a unique index that is not the OBJECTID?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 19:11:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1346846#M55729</guid>
      <dc:creator>timcneil</dc:creator>
      <dc:date>2023-11-07T19:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Unexplained behaviour when upserting a hosted feature layer in AGO with UI and API</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1346902#M55730</link>
      <description>&lt;P&gt;I ran through your repro case above, and if the ID field is used as the unique identifier (instead of system-generated OBJECTID), the number of features in the layer after upserting will be correct (&lt;SPAN&gt;31058).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As a best practice, we don't recommend using the OBJECTID field as a unique identifier for updating data. While it can work in some scenarios, there are some cases where the values will not be as expected. For example, if the layer is truncated the OBJECTIDs for the newly added features will not start at 1. They will pick up on the next value after the truncated feature OBJECTIDs.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 20:56:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1346902#M55730</guid>
      <dc:creator>timcneil</dc:creator>
      <dc:date>2023-11-07T20:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Unexplained behaviour when upserting a hosted feature layer in AGO with UI and API</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1347040#M55734</link>
      <description>&lt;P&gt;Greetings&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/512339"&gt;@timcneil&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I was not aware of the recommendation. Is this documented anywhere? If not, this could be included as an enhancement to the documentation, don't you think?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 08:10:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1347040#M55734</guid>
      <dc:creator>MiguelParedes</dc:creator>
      <dc:date>2023-11-08T08:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unexplained behaviour when upserting a hosted feature layer in AGO with UI and API</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1347122#M55737</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2690"&gt;@MiguelParedes&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;We do plan to include this recommendation in the documentation. I have submitted an enhancement request.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Taylor&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 13:55:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1347122#M55737</guid>
      <dc:creator>timcneil</dc:creator>
      <dc:date>2023-11-08T13:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Unexplained behaviour when upserting a hosted feature layer in AGO with UI and API</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1347276#M55741</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/512339"&gt;@timcneil&lt;/a&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2690"&gt;@MiguelParedes&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for responding! I've changed the OBJECTID to some other identification and it worked:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StijnSchoutenTheGISLord_0-1699464069206.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85391i2C8DCFA973887871/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StijnSchoutenTheGISLord_0-1699464069206.png" alt="StijnSchoutenTheGISLord_0-1699464069206.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Happy with result and response, thanks!!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I was not aware of the standard/recommendation so nice to see the plan to get it included in the documentation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 17:22:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/unexplained-behaviour-when-upserting-a-hosted/m-p/1347276#M55741</guid>
      <dc:creator>StijnSchoutenTheGISLord</dc:creator>
      <dc:date>2023-11-08T17:22:18Z</dc:date>
    </item>
  </channel>
</rss>

