<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FeatureLayerCollection.replicas.create always returns the correct tables but 0 records in the tables in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711378#M11985</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/339785"&gt;@Trippetoe&lt;/a&gt;&amp;nbsp;This is a great question. I'm looking into it now. Can you provide a code snippet that shows how you are setting up the replica? What are the sync options, geometry and layer queries look like?&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jun 2026 20:42:42 GMT</pubDate>
    <dc:creator>KenGalliher1</dc:creator>
    <dc:date>2026-06-30T20:42:42Z</dc:date>
    <item>
      <title>FeatureLayerCollection.replicas.create always returns the correct tables but 0 records in the tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1710923#M11983</link>
      <description>&lt;P&gt;Hi there. I have a python script that attempts&amp;nbsp;to export a hosted feature service as a file geodatabase using the&amp;nbsp; python api's featurelayercollection.replicas.create() method. I am running python 3.11.10 and arcgis api 2.3.0&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The service details:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;- One feature layer (id: 0, geometry type: point) with attachments&lt;BR /&gt;- One related table (id: 1) with attachments&lt;BR /&gt;- Sync is enabled&lt;BR /&gt;- supportsSyncModelNone = true&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;the replicas.create() operation consistently returns a file geodatabase with the correct schema but 0 rows in all tables, regardless of parameters used.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What works:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Using the AGOL Item Details page to Export as file geodatabase.&lt;/LI&gt;&lt;LI&gt;A direct query on layer 0 returns the expected 27 records&lt;/LI&gt;&lt;LI&gt;Running createReplica manually via the REST Services Directory HTML form returns the expected number of records&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;What I've have tried (all returning 0 rows):&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;syncModel=none with no geometry filter&lt;/LI&gt;&lt;LI&gt;syncModel=none with geometry set to the service's full extent&lt;/LI&gt;&lt;LI&gt;Adding layerQueries with where=1=1, useGeometry=false, includeRelated=true, queryOption=useFilter for both layers&lt;/LI&gt;&lt;LI&gt;syncDirection=bidirectional&lt;/LI&gt;&lt;LI&gt;geometryType=esriGeometryPoint&lt;/LI&gt;&lt;LI&gt;async=true and async=false&lt;/LI&gt;&lt;LI&gt;layers as comma-separated string (0,1) and as JSON array ([0,1])&lt;/LI&gt;&lt;LI&gt;using an empty querylayers&lt;/LI&gt;&lt;LI&gt;using a populated queryLayers with filter set to 1=1&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Any thoughts on how to get the expected number of records returned?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2026 23:00:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1710923#M11983</guid>
      <dc:creator>Trippetoe</dc:creator>
      <dc:date>2026-06-29T23:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayerCollection.replicas.create always returns the correct tables but 0 records in the tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711378#M11985</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/339785"&gt;@Trippetoe&lt;/a&gt;&amp;nbsp;This is a great question. I'm looking into it now. Can you provide a code snippet that shows how you are setting up the replica? What are the sync options, geometry and layer queries look like?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2026 20:42:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711378#M11985</guid>
      <dc:creator>KenGalliher1</dc:creator>
      <dc:date>2026-06-30T20:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayerCollection.replicas.create always returns the correct tables but 0 records in the tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711397#M11987</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/339785"&gt;@Trippetoe&lt;/a&gt;&amp;nbsp;I was not able to reproduce the missing rows with a file geodatabase or SQLite geodatabase. Here is the code I used. Let me know if you have any questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import time
import tempfile
from arcgis.features.layer import FeatureLayerCollection
from arcgis.gis import GIS
from arcgis import geometry

gis = GIS(profile="your_online_profile")
item = gis.content.get("401876e7f782419dbd29974ce8a4e11b")
flc = FeatureLayerCollection(item.url, gis)

output_gdb_path = tempfile.TemporaryDirectory()

service_url = flc.url

extent = {
    "xmin": -13238397.099502765,
    "ymin": 3923105.9219284547,
    "xmax": -13037402.432768419,
    "ymax": 4065046.3578960407,
}
geom_filter = geometry.filters.envelope_intersects(extent)
sync_options = {"syncDataOptions": 260}
layer_queries = {
    "0": {"queryOption": "useFilter", "useGeometry": True},
    "2": {"queryOption": "useFilter", "useGeometry": False},
}

# For file gdb, the sync model must be none
# For mobile gdb, use "perLayer" or "perReplica"
sync_model = "none"
data_format = "filegdb"
replica_options = {
    "replica_name": f"ReplicaTest_{int(time.time())}",
    "layers": [0, 2],
    "layer_queries": layer_queries,
    "geometry_filter": geom_filter,
    "replica_sr": {"wkid": 102642, "latestWkid": 2226},
    "transport_type": "esriTransportTypeUrl",
    "return_attachments": True,
    "attachments_sync_direction": "bidirectional",
    "sync_model": sync_model,
    "data_format": data_format,
    "replica_options": sync_options,
    "out_path": output_gdb_path.name,
    "sync_direction": "bidirectional",
}

try:
    res = flc.replicas.create(**replica_options)
    print(res)
except Exception as ex:
    print("Create Replica failed:", str(ex))
finally:
    output_gdb_path.cleanup()&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Jun 2026 21:13:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711397#M11987</guid>
      <dc:creator>KenGalliher1</dc:creator>
      <dc:date>2026-06-30T21:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayerCollection.replicas.create always returns the correct tables but 0 records in the tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711424#M11988</link>
      <description>&lt;P&gt;Thanks for your response. I'm a bit behind you so i'll answer this response first.&amp;nbsp; Here's my python code that uses `replicas.create()`. As noted in my question, the code returns an empty file geodatabase...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;edit_date_filter = "EditDate &amp;gt;= '"+str(last_successful_run_date)+"'"
feat_srvc = arcgis.features.FeatureLayerCollection(settings.AGOL_FEATURE_SERVICE_URL, agol_security_token)

export_job = feat_srvc.replicas.create(
	replica_name='NameDoesNothing',
	layers=[settings.FS_IDX, settings.CONDITION_IDX],                          
	layer_queries={
		str(settings.FS_IDX):{
			"queryOption":"useFilter", "where":edit_date_filter},
		str(settings.CONDITION_IDX):{
			"queryOption":"useFilter", "where":edit_date_filter}
	},
	geometry_filter=None,
	replica_sr=None,
	transport_type='esriTransportTypeUrl',
	return_attachments=True,
	return_attachments_databy_url=False, 
	asynchronous=True, 
	attachments_sync_direction='bidirectional',
	sync_model='none', 
	data_format="filegdb",
	replica_options=None, 
	wait=False,
	out_path=settings.DOWNLOAD_DIR,
	sync_direction=None, 
	target_type='client')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just for good measure, i'm including this 'direct request' against the createReplicas endpoint. the results are the same. a perfectly fine, but empty, file geodatabase.....&lt;/P&gt;&lt;LI-CODE lang="python"&gt;url = f"{feat_srvc.url}/createReplica"

data = {
	'f': 'json',
	'replicaName': 'test_direct4',
	'layers': '[0,1]',
	'layerQueries': '{"0": {"where": "1=1", "useGeometry": false, "includeRelated": true, "queryOption": "useFilter"}, "1": {"where": "1=1", "useGeometry": false, "includeRelated": true, "queryOption": "useFilter"}}',
	'geometryType': 'esriGeometryPoint',
	'returnAttachments': 'false',
	'syncModel': 'none',
	'syncDirection': 'bidirectional',
	'dataFormat': 'filegdb',
	'async': 'false',
	'token': agol_security_token._con.token
}

response = requests.post(url, data=data)
print(response.json())

dl_url = response.json().get('responseUrl')
resp = requests.get(url=dl_url, params={'token': agol_security_token._con.token})
zipped = zipfile.ZipFile(io.BytesIO(resp.content))&lt;/LI-CODE&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 01 Jul 2026 17:19:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711424#M11988</guid>
      <dc:creator>Trippetoe</dc:creator>
      <dc:date>2026-07-01T17:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayerCollection.replicas.create always returns the correct tables but 0 records in the tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711436#M11990</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/108851"&gt;@KenGalliher1&lt;/a&gt;&amp;nbsp;Thanks for the code example. I changed the code as necessary for my hosted feature service and ran it. unfortunately, i got the same results: an other wise perfect file geodatabase with my related tables, attachment tables, etc - but there we no rows in the feature class, the related table, nor either of the attachment tables. The only table with any rows was the GDB_ServiceItems table.&lt;/P&gt;&lt;P&gt;I don't know why really, but a hunch is that the attachments in the related table are causing the problem. Does your hosted feature service have attachments enabled on the related table (index 2 i believe in your example)?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2026 23:29:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711436#M11990</guid>
      <dc:creator>Trippetoe</dc:creator>
      <dc:date>2026-06-30T23:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayerCollection.replicas.create always returns the correct tables but 0 records in the tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711669#M11991</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/339785"&gt;@Trippetoe&lt;/a&gt;&amp;nbsp;Yes, I enabled and added attachments on the feature layer and the table. Thanks for providing your parameters. I'll test some of those in my code. I'll let you know what happens.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2026 16:09:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711669#M11991</guid>
      <dc:creator>KenGalliher1</dc:creator>
      <dc:date>2026-07-01T16:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayerCollection.replicas.create always returns the correct tables but 0 records in the tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711701#M11993</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/108851"&gt;@KenGalliher1&lt;/a&gt;&amp;nbsp;I noticed that i left a bad parameter in my code example (I've been trying every option to see what might matter and some slop did not get removed).&amp;nbsp; The right parameter is&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;attachments_sync_direction='bidirectional',&lt;/LI-CODE&gt;&lt;P&gt;In my original post i had that value as 'download', which does not work.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2026 17:18:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollection-replicas-create-always/m-p/1711701#M11993</guid>
      <dc:creator>Trippetoe</dc:creator>
      <dc:date>2026-07-01T17:18:54Z</dc:date>
    </item>
  </channel>
</rss>

