How to use Add Attachments tool to add attachments to AGOL replica

04-18-2017 05:03 PM
New Contributor II

I have a Feature Service in ArcGIS Online.  It has attachments enabled.  I can create a local copy and add attachments to the Feature Service using the Attachment Manager in an edit session.  I can successfully sync that copy with the AGOL service and see the attachments online.

I have about 1000 attachments to add.  I've created a match table to add those attachments.  When I run the Add Attachments tool with my local copy of the feature service in an edit session, I get the following error:

ERROR 001602: fsD8512A816DB3409B8171CAD448C521FE.gdb is being edited.

When I run outside of an edit session, the tool runs successfully, but no attachments are made.  The Match Table has 2 fields: a MATCHID field with the OBJECTID of the rows that I want to add and a FILENAME field with the paths to the files I want to add.  The files are there and can successfully be added using the Attachment manager in an edit session.  The MATCHIDs and OBJECTIDs match up.  I can see no reason that this shouldn't be working.

I actually pretty sure I'm doing this correctly.  I really want to know if anyone has successfully completed this process; namely adding a list of attachments to a ArcGIS Online Feature service in bulk.

0 Kudos
2 Replies
New Contributor II

Fixed my first mistake (MATCHID was a text field instead of a long field to match OBJECTID).  Now we go back to the initial error: Since you can't be in an edit mode to use AddAttachments_manager, there is nothing to sync.  So when I synchronize my local copy, the attachments (which are in the attachment table related to the local copy of the feature) are not included in the sync.  My only guess is that synchronize sends the list of events that occurred during edit mode, ignoring those that occurred outside edit Add Attachments.

Does anyone know of a way to add attachments to an AGOL feature service in bulk?

Esri Frequent Contributor

Hi Alan,

You may want to look in to writing a script making a direct rest call to add attachments to the hosted feature service directly. You can add some logic to bulk add the attachments.

Add attachments is also included in the ArcGIS API for Python: arcgis.features.managers module — arcgis 1.0.1 documentation