Branch Versioning Edit Error

06-03-2022 02:23 AM
Occasional Contributor

Hi all, I'm trying to use the v2.0.0 API for branch versioning and I'm hitting an unexpected issue.  I can create and open a version without any issues, but my edit() call against the version is failing.  I expect I'm passing in an incorrect object somewhere but haven't seen any samples using the edit() call.

Here's my current code:

versionName = f"test_ver"
qualVersionName = f"{GIS_USERNAME}.{versionName}"
createSuccess = versionManager.create(versionName)
with versionManager.get(qualVersionName, mode="edit") as version:
    featureLayer = version.layers[0]
    update = {"attributes": {"OBJECTID": 1, "TEST_ATTR": 1}}
    editResult = version.edit(featureLayer, updates=[update])

When it hits the edit() call, I get this error from, caught at line 1032:

'Multipart Encoder' object has no attribute 'decode'

I've tried not using the context manager with version, as well as explicitly making start_editing() calls and setting the mode property, get the same result regardless.  I've also tried passing in a feature layer object that I opened in the normal fashion rather than the one from the version, also the same result.

I've created the Python environment by cloning my ArcGIS Pro environment (with v1.9.1) and then using the command line to upgrade the Python API version (conda install -c esri arcgis=2.0.0).  There were no errors, I haven't seen anything to indicate there are any issues with the environment, and I've been able to make other API calls like queries, etc., without issue.

Let me know if you've run into anything like this, or if anything in my code looks unusual.  Thanks!

0 Kudos
3 Replies
by Anonymous User
Not applicable

Hi @MobiusSnake - I tested this and the following formatting worked to edit a feature. Query featureLayer to return a list of features, and then create a feature template using a list comprehension to query the specific feature you want to edit. Then assign a new variable to the feature template, then edit the new variable's field you want to change and use that new variable as the argument for updates. Try these lines after line 5:


feat_list = featureLayer.query(where="1=1").features
feat_template = [f for f in feat_list if f.attributes["OBJECTID"] == 1][0]
feat_to_edit = feat_template
feat_to_edit.attributes["TEST_ATTR"] = 1
editResult = version.edit(featureLayer, updates=[feat_to_edit])


Give this a try and see if that updates featureLayer

0 Kudos
Occasional Contributor

Hey, I just saw my notification for this, thanks for the feedback.  It seemed to be an issue with my Python environment, I cloned a new one and reinstalled the 2.0 API.  The edit call worked this time, but now I'm getting errors elsewhere (specifically on the stop editing call).  For now I've abandoned it and I'm using REST API and requests to do what I need.

0 Kudos
New Contributor III

Hi @MobiusSnake , I am also trying to implement reconcile and post the branch version using the same logic but throws error "Version already in edit mode. Only one user can be editing a branch version." Can you share some idea to implement the #ArcPy #BranchVersion #ReconcilePost


0 Kudos