AnsweredAssumed Answered

Error Syncing Replica to Hosted Feature Layer

Question asked by panoramicgis on Aug 7, 2019
Latest reply on Sep 5, 2019 by panoramicgis

Hello,

 

I am using ArcGIS Runtime for .NET 100.5, and attempting to sync a .geodatabase replica to a hosted feature layer in ArcGIS Online. I am getting an error that states 'unable to synchronize replica'. When I look at the error details,  the message is 'Importing delta data changes failed'. 

 

To create the hosted feature layer, I created a Map in ArcGIS Pro with 30 point, line and polygon feature layers, and then used the tools to Share the map to an ArcGIS Online organizational account. I set the web map to be 'offline enabled', and I also enabled the 'Sync' option on the Hosted Feature Layer.

 

I was able to create the offline .geodatabase file with just a few lines of code thanks to the sample code provided by ESRI (see below), and I also used sample code to attempt to sync the replica (see below). I'm not sure how to troubleshoot this issue as there is little information provided in the error message. Has anyone else had a problem with this particular error, or have suggestions as to how to track more info about the error down?

 

Thanks!

Jen

 

Creating the replica

 

SpatialReference sp = new SpatialReference(3857); //Web mercator wkid

// Get the extent of the current map

 

//Envelope extent = mainMap.InitialViewpoint.TargetGeometry.Extent as Envelope;
Envelope extent = new Envelope(-9972280.458, 6146072.133, -9907308.984, 6193615.965, sp);

 

// Create a task for generating a geodatabase (GeodatabaseSyncTask).
_gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri);

 

// Get the default parameters for the generate geodatabase task.
GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent);

 

// Create a generate geodatabase job.
GenerateGeodatabaseJob generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath);

 

// Start the job.
generateGdbJob.Start();

 

// Get the result of the job.
_resultGdb = await generateGdbJob.GetResultAsync();

 

Syncing the replica with the server

 

Geodatabase resultGdb = await Esri.ArcGISRuntime.Data.Geodatabase.OpenAsync(_gdbPath);

 

 

// Create parameters for the sync task.
SyncGeodatabaseParameters parameters = new SyncGeodatabaseParameters()
{
     GeodatabaseSyncDirection = SyncDirection.Bidirectional,
     RollbackOnFailure = false
};

 

parameters.LayerOptions.Clear();

 

// Get the layer ID for each feature table in the geodatabase, then add to the sync job.
foreach (GeodatabaseFeatureTable table in resultGdb.GeodatabaseFeatureTables)
{

     // Get the ID for the layer.
     long id = table.ServiceLayerId;

 

     // Create the SyncLayerOption.
     SyncLayerOption option = new SyncLayerOption(id);

 

     // Add the option.
     parameters.LayerOptions.Add(option);
}

 

// Create job.
SyncGeodatabaseJob job = _gdbSyncTask.SyncGeodatabase(parameters, resultGdb);

job.Start();

 

// Wait for the result.
await job.GetResultAsync();

 

// Do the remainder of the work.
HandleSyncCompleted(job);

Outcomes