I have a branch versioned service layer on ArcGIS Portal. I want editors to use ArcGIS Pro to open a map in a ArcGIS Pro project and use their respective versions of this layer to create new features based off of a reference table that has all of the attributes for the features after they've been drawn in.

I would like the editor to copy and paste the UID from the reference table to their version of feature layer and move onto drawing the next feature. A script will run during non-business hours to run a post from the editor version to the default version leaving the newly created features' attributes blank except for the UIDs.

I would then like the script to populate these attributes using an update cursor.

I have successfully signed into portal using arcgis.GIS and generated the necessary access token used in my url query, I have also done the following:

# list of UIDs with null attribute values in feature layer named "UIDS"
# make a dict named "updates" using each item in UIDS as a key and the pair being the attribute values to be carried over to the feature layer

# import modules
import arcpy
from arcgis.gis import GIS

# set up layer for editing
workspace = r"https://url.org/arcgis/rest/services/Map_Docs/FeatureServer?token=" + token
smd = r"https://url.org/arcgis/rest/services/Map_Docs/FeatureServer/0?token=" + token
lyr = "lyr"

# I have done all the necessary steps to connect to portal at this point

arcpy.management.ChangeVersion(lyr, 'BRANCH', "sde.DEFAULT")

This is where things go sideways:

with arcpy.da.Editor(workspace) as edit:
    with arcpy.da.UpdateCursor(lyr, ["UID","Date", "Street"]) as rows:
        for row in rows:
            for k, v in updates.items(): # k =m UID, v = row[1:2]
                if k == row[0]:
                    row[1] = v[0]
                    row[2] = v[1]

This is the error I get:

RuntimeError                              Traceback (most recent call last)
In  [25]:
Line 1:     with arcpy.da.Editor(workspace) as edit:

RuntimeError: cannot open workspace

What do I need to do to open the workspace? I've already generated a token and have successfully tested the query string by pasting it into a private browse for access to both the feature service (FeatureServer/0?token=" + token) and the feature server (FeatureServer?token=" + token)

1 Answer 1


I am fairly confident that Branch Versioning doesn't support direct editing. I think you are going to need to switch to Traditional versioning to use your update cursor. Or look to the GIS module to run your edits through the REST service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.