CreateReplica with layerQueries Fails

389
2
Jump to solution
01-04-2019 07:49 PM
SimonJackson
Occasional Contributor III

I have a public hosted feature in ArcGIS Online (test data) which has SYNC enabled.

Using the Python API I want to download a file geodatabase, but also include a WHERE clause to download a subset of the data. 

I am having a problem with the WHERE clause.

I can perform a standard REST query to get some records from an individual layer.

WHERE type='JAM'

I can also successfully download a file geodatabase using the createReplica endpoint via REST:

createReplica OK

However, if I want to apply a WHERE clause, I am having some problems getting the layerQueries parameter to work via REST

{"0":{"queryOption": "useFilter", "where": "type = JAM", "useGeometry": false}}{"0":{"where": "type = JAM"}}

Both of the above result in:

Exporting data for layer 0 failed.

Can anyone point out what is wrong with my layerQueries param, I am sure it must be something simple.

I intend on using this via Python as below, but I figure I need to be able to get it work directly against the REST API before troubleshooting in Python.

replica = waze_flc.replicas.create(replica_name = 'Waze_Download',
                                   layer_queries = {"0":{"queryOption": "useFilter", "where": "type = JAM", "useGeometry": false}},
                                   layers = '0',
                                   data_format = 'filegdb',
                                   out_path = './download')

 

The field I actually need to perform the WHERE clause on is a timestamp, to get the last 24 hours of data.

0 Kudos
1 Solution

Accepted Solutions
simoxu
by MVP Regular Contributor
MVP Regular Contributor

Hi Simon,

Could you try to put a pair of single quotation mark around JAM in your layerQueries?

This works for me in the rest endpoint, I guess it should work in the python code as well.

{ "0":{"where": "type= 'JAM'" }}

To be safe, I would specify the queryOption which was added in 10.2 according to the REST API document:

{ "0":{"queryOption":"useFilter", "where": "type= 'JAM'" }}

View solution in original post

0 Kudos
2 Replies
simoxu
by MVP Regular Contributor
MVP Regular Contributor

Hi Simon,

Could you try to put a pair of single quotation mark around JAM in your layerQueries?

This works for me in the rest endpoint, I guess it should work in the python code as well.

{ "0":{"where": "type= 'JAM'" }}

To be safe, I would specify the queryOption which was added in 10.2 according to the REST API document:

{ "0":{"queryOption":"useFilter", "where": "type= 'JAM'" }}

0 Kudos
SimonJackson
Occasional Contributor III

Hey Simo, hope things are good with you.

Too easy! Works a charm.  Ashamed I didn't work that one out.  

Now onto tweaking the expression to filter using dates.  

Thanks.

replica = waze_flc.replicas.create(replica_name = 'Waze_Download',
                                   layer_queries = {"0":{"queryOption": "useFilter", "where": "type = 'JAM'", "useGeometry": "false"}},
                                   layers = '0',
                                   data_format = 'filegdb',
                                   out_path = './download')‍‍‍‍‍
0 Kudos