<?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: Branch version Reconcile &amp;amp; Post Error in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/branch-version-reconcile-amp-post-error/m-p/1378571#M9628</link>
    <description>&lt;P&gt;Hi Sirish,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you ever found a solution for this problem or found out what caused it?? I have the same problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, Rick&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2024 09:44:34 GMT</pubDate>
    <dc:creator>RJankowski</dc:creator>
    <dc:date>2024-02-06T09:44:34Z</dc:date>
    <item>
      <title>Branch version Reconcile &amp; Post Error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/branch-version-reconcile-amp-post-error/m-p/1209829#M7714</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;We are using&lt;/P&gt;&lt;P&gt;ArcGIS enterprise version: 10.9.1&lt;/P&gt;&lt;P&gt;ArcGIS Pro: V 3.0&lt;/P&gt;&lt;P&gt;Database: Postgres&lt;/P&gt;&lt;P&gt;We have enabled 'Branch version' on the feature dataset and published as "Feature services".&lt;/P&gt;&lt;P&gt;We are able to 'reconcile &amp;amp; post' using&amp;nbsp; GP Tool in ArcGIS Pro.&lt;/P&gt;&lt;P&gt;By using the following ArcGIS API for Python code we are trying to automate the&amp;nbsp;'reconcile &amp;amp; post'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Name:        Branch Version Reconcile &amp;amp; Post using the ArcGIS Python API

##----------------- Modules -------------------------------------------------------------
# import modules
import arcpy, datetime, requests, os
import arcgis.features
from arcgis.gis import GIS
import Config
# Disable warnings
requests.packages.urllib3.disable_warnings()
##----------------------------- Input &amp;amp; Derived Parameters ----------------------------------------
fs_url = arcpy.GetParameter(0)
version_name_txt = arcpy.GetParameter(1)
if fs_url.endswith("FeatureServer"):
    base_url = os.path.dirname(fs_url)
else:
    base_url = os.path.dirname(os.path.dirname(fs_url))
#--------------------------------------------------------------------------------------------------
try:
    start_time = datetime.datetime.now()
    # Service URLs and GIS object
    arcpy.AddMessage(f"connecting to {Config.portal_params.portal_url}...")
    portal = GIS(
        url=Config.portal_params.portal_url,
        password=Config.portal_params.p_password,
        username=Config.portal_params.p_username,
    )
    # Create a dict of service urls
    services = ["FeatureServer", "VersionManagementServer"]
    service_urls = {url: base_url + '/' + url for url in services}
    # The Feature Server (service URL)
    version_mgmt_svc = service_urls["VersionManagementServer"]
    vms = arcgis.features._version.VersionManager(service_urls["VersionManagementServer"], portal)
    arcpy.AddMessage(f'Version Management Service: {vms}')
    # Check if the new version exists and get the fully qualified version name from the version's properties ('owner.versionName')
    _version = [x for x in vms.all if version_name_txt in x.properties.versionName]
    fq_version_name = _version[0].properties.versionName
    arcpy.AddMessage(f'Fully qualified version name: {fq_version_name}')
   
    # Reconcile the version with Default
    with vms.get(fq_version_name, "edit") as version:  # use "edit" to run start_editing
        # Reconcile the version. Post if there are no conflicts detected.
        try:
            arcpy.AddMessage(f"Reconciling...")
            reconcile_res = version.reconcile(end_with_conflict=True, with_post=True)
            arcpy.AddMessage(f"Results of Reconcile &amp;amp; Post: {reconcile_res}")
            if not reconcile_res:
                arcpy.AddMessage(f"Reconciling the version {version.properties.versionName} failed.")
                raise Exception(f"Reconciling the version {version.properties.versionName} failed.")
                out_code = 1
            arcpy.AddMessage(f"Reconciled and posted version: {version.properties.versionName}")
            arcpy.AddMessage(f"Output Code: {reconcile_res}")
            out_code = 0
            arcpy.SetParameter(2, out_code)
            arcpy.AddMessage(out_code)
            end_time = datetime.datetime.now()
            elapsed_time = end_time - start_time
            arcpy.AddMessage(f"Dataset was locked for {elapsed_time.total_seconds()} secs")
        except Exception as ex:
            arcpy.AddMessage(f'Exception : {str(ex)}')
            out_code = 1
except Exception as ex:
    arcpy.AddMessage(str(ex))
    out_code = 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we execute this in ArcGIS Pro, we are getting error as "&lt;SPAN&gt;Version already in edit mode. Only one user can be editing a branch version."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Appreciate help on this please.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sirish&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 12:57:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/branch-version-reconcile-amp-post-error/m-p/1209829#M7714</guid>
      <dc:creator>sirishb</dc:creator>
      <dc:date>2022-09-06T12:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Branch version Reconcile &amp; Post Error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/branch-version-reconcile-amp-post-error/m-p/1378571#M9628</link>
      <description>&lt;P&gt;Hi Sirish,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you ever found a solution for this problem or found out what caused it?? I have the same problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, Rick&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 09:44:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/branch-version-reconcile-amp-post-error/m-p/1378571#M9628</guid>
      <dc:creator>RJankowski</dc:creator>
      <dc:date>2024-02-06T09:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Branch version Reconcile &amp; Post Error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/branch-version-reconcile-amp-post-error/m-p/1378615#M9629</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;Before reconcile, we implemented additional logic, if the version is locked we did '&lt;FONT face="inherit"&gt;purgeLock'. After this &lt;/FONT&gt;implementation&lt;FONT face="inherit"&gt;&amp;nbsp;we &lt;/FONT&gt;didn't get any error.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sirish&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 14:01:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/branch-version-reconcile-amp-post-error/m-p/1378615#M9629</guid>
      <dc:creator>sirishb</dc:creator>
      <dc:date>2024-02-06T14:01:45Z</dc:date>
    </item>
  </channel>
</rss>

