Hi All,
ArcGIS enterprise version: 10.9.1 & ArcGIS Pro 2.9 & Python version 3.7.11
Versioning type: Branch Version
We have published "Feature" services with "Version Management" capability.
Requirement:
1) Field Users perform edits on "Feature Service"
2) Using ArcGIS Workflow manager automate the "Reconcile & Post" activity using GP Service
Implemented Steps:
1) We have developed a python script (API for Python) and created a toolbox.
2) When we execute the same in ArcGIS Pro, it is working fine.
3) While trying to publish as GP Service using "Share Web Tool", getting the following errors
4) Getting the same error for the both options
Python Script:
# Tool: Branch Version Reconcile & Post using the ArcGIS Python API
##-----------------------------------------------------------------------------------------------
##----------------- Modules -------------------------------------------------------------
# import modules
import arcpy, datetime, requests, os
import arcgis.features
from arcgis.gis import GIS
#import Config
import time
import urllib.parse
# Disable warnings
requests.packages.urllib3.disable_warnings()
##----------------------------- Input & Derived Parameters ----------------------------------------
arcpy.env.overwriteOutput = True;
ftr_service =arcpy.GetParameterAsText(0)
vms_service = arcpy.GetParameterAsText(1)
version_name =arcpy.GetParameterAsText(2)
out_code = arcpy.GetParameterAsText(3)
# ftr_service = "https://<WEBADAPTOR NAME>/arcgis/rest/services/testFeatureService/FeatureServer"
# vms_service = "https://<WEBADAPTOR NAME>/arcgis/rest/services/testFeatureService/VersionManagementServer"
# version_name = "admin.testVersion"
# out_code = 0
print("Start GP Tool")
arcpy.AddMessage("Start GP Tool")
base_url = ftr_service
#--------------------------------------------------------------------------------------------------
try:
start_time = datetime.datetime.now()
# Service URLs and GIS object
portalURL = "https://<WEBADAPTOR NAME>/portal/home/index.html"
portal = GIS(url = portalURL, username = 'username', password = 'password', verify_cert = False)
# Create a VersionManagementServer of service url
version_mgmt_svc = vms_service
vms = arcgis.features._version.VersionManager(version_mgmt_svc, portal)
print(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 in x.properties.versionName]
fq_version_name = _version[0].properties.versionName
print(_version[0].properties)
arcpy.AddMessage(f'Version properties: {_version[0].properties}')
# Reconcile the version with Default
with vms.get(version_name, mode="edit") as version:
print("Start reconcile...")
try:
arcpy.AddMessage(f"Reconciling...")
print(f"Reconciling...")
reconcile_res = version.reconcile(end_with_conflict=True, with_post=True)
arcpy.AddMessage(f"Results of Reconcile & Post: {reconcile_res}")
print(f"Results of Reconcile & Post: {reconcile_res}")
if not reconcile_res:
arcpy.AddMessage(f"Reconciling the version {version.properties.versionName} failed.")
out_code = 0
raise Exception(f"Reconciling the version {version.properties.versionName} failed.")
arcpy.AddMessage(f"Reconciled and posted version: {version.properties.versionName}")
arcpy.AddMessage(f"Output Code: {reconcile_res}")
out_code = 1
arcpy.SetParameter(3, 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 2: {str(ex)}')
print(f'Exception 2: {str(ex)}')
out_code = 0
arcpy.AddMessage(out_code)
arcpy.SetParameter(3, out_code)
except Exception as ex:
arcpy.AddMessage(f'Exception 1: {str(ex)}')
print(f'Exception 1: {str(ex)}')
out_code = 0
arcpy.AddMessage(out_code)
arcpy.SetParameter(3, out_code)
Any suggestions please.
Regards,
Sirish
Solved! Go to Solution.