How can one export both the layers and tables from a feature layer in AGOL while respecting the where clause?
The following syntax exports the layers successfully, respecting the where_clause, but the tables do not export. I'm guessing I need something other than a comma in between the layers[] and tables[]
output_file = observations.export(title="Observations", export_format="File Geodatabase", parameters={"layers" :[{"id" : 0, "where" : where_clause},{"id" : 1, "where" : where_clause},{"id" : 2, "where" : where_clause},{"id" : 3, "where" : where_clause}], "tables":[{"id":4},{"id":5},{"id":6},{"id":7},{"id":8},{"id":9},{"id":10}]})
If, instead, I use the following syntax, both the layers and tables export successfully, but the where_clause is ignored:
output_file = observations.export(title="ObservationsTables", export_format="File Geodatabase", parameters= {"tables":[{"id":4, "where" : where_clause},{"id":5, "where" : where_clause},{"id":6, "where" : where_clause},{"id":7, "where" : where_clause},{"id":8, "where" : where_clause},{"id":9, "where" : where_clause},{"id":10, "where" : where_clause}]})
So, how do I get both the layers and tables to export according to the where_clause? I have verified the where_clause is successful in the first export, but just in case, here's the test where_clause I'm using:
where_clause = "CreationDate > '7/1/2020' and EditDate > '7/1/2020'"
Turns out I was over complicating the issue - all can be done within "layers", whether layers or tables, so the proper syntax is:
output_file = observations.export(title="ObservationsTables", export_format="File Geodatabase", parameters= {"layers":[{"id":0, "where" : where_clause},{"id":1, "where" : where_clause},{"id":2, "where" : where_clause},{"id":3, "where" : where_clause},{"id":4, "where" : where_clause},{"id":5, "where" : where_clause},{"id":6, "where" : where_clause},{"id":7, "where" : where_clause},{"id":8, "where" : where_clause},{"id":9, "where" : where_clause},{"id":10, "where" : where_clause}]})
or, simplified:
param = {"layers" :[{"id" : 0, "where" : where_clause}, {"id" : 1, "where" : where_clause}, {"id" : 2, "where" : where_clause}, {"id" : 3, "where" : where_clause}, {"id" : 4, "where" : where_clause}, {"id" : 5, "where" : where_clause}, {"id" : 6, "where" : where_clause}, {"id" : 7, "where" : where_clause}, {"id" : 8, "where" : where_clause}, {"id" : 9, "where" : where_clause}, {"id" : 10, "where" : where_clause}]}
with:
output_file = observations.export(title="Observations", export_format="File Geodatabase", parameters=param)
Many thanks to Calvin Kwon, Esri, for the solution!