I have a hosted FeatureLayer in a Webmap that contains multiple features for data collections that will be used across multiple projects. I'd like to be able to pull down data and attachments from those layers using a layer query in the create replica wizard . For this example I have layers 0-3, all layers have a common attribute, "Project_Number". I would like to do something similar to the example below. So far I have tested the first line, while it produces a url to download the data the replica creation fails. Unfortunately it does not provide an error number, only that it failed. Any insight would be greatly appreciated.
EXAMPLE:
{"0":{"where":"Project_Number=842"}}
{"1":{"where":"Project_Number=842"}}
{"2":{"where":"Project_Number=842"}}
{"3":{"where":"Project_Number=842"}}
CHECK REPLICA STATUS ERROR:
Solved! Go to Solution.
Hi Chris,
Try using these for LayerQueries;
{"4":{"where":"TEAM='1'"}}
I think you need to use single quotes (' ') to enter values for where clause. Doesn't matter if it is Numeric or string field. I tried the same on my service and I could download the attachments.
1. Data tab of service
2. Query: {"0":{"where":"NUMBER='100'"}}
Please let me know if it works.
Best,
Hemant A
Figured this out.
•{"0":{"where":"Project_Number=842'", "where":"Project_Number=845'", "where":"Project_Number=895'"}}
Supriya, thank you so much for responding to my post. Yes, the create replica works when the query is left out. I am Creating the replica from the Rest url, see below. You'll notice the url appears as it should. When I click the url I get a failed status and error.
Do any of the records in layer 4 (above) actually have attachments? I found that if I tried something similar to what you showed in the screenshot above on a layer that didn't have any attachments I got the "Error: Exporting data for layer X failed". But, if I tried the same thing above on a layer with attachments it succeeded.
All records in Layer 4 have attachments. Could there be something in the feature layer settings that I'm overlooking that doesn't allow features & attachments to be downloaded with a query?
Hi Chris,
Try using these for LayerQueries;
{"4":{"where":"TEAM='1'"}}
I think you need to use single quotes (' ') to enter values for where clause. Doesn't matter if it is Numeric or string field. I tried the same on my service and I could download the attachments.
1. Data tab of service
2. Query: {"0":{"where":"NUMBER='100'"}}
Please let me know if it works.
Best,
Hemant A
Hemant, thank you so much. The query string work flawlessly. Thanks again!
Sorry for the multiple replies. How would you string together the query if you wanted to pull Team 1's data from multiple layers? Lets say layers 4 & 7?
You would add it to the original line, but keep it inside that first bracket. Look at this example here:
Syntax: layerQueries={ Layer_or_tableID1 : {"where":"attribute query" , "useGeometry" : true | false, "includeRelated" : true | false}, Layer_or_tableID2: {.}}
Create Replica—ArcGIS REST API: Services Directory | ArcGIS for Developers
So if I took the first example you posted in this thread and corrected it, it would look something like this:
{"0":{"where":"Project_Number='842'"}, "1":{"where":"Project_Number='842'"}, "2":{"where":"Project_Number='842'"}, "3":{"where":"Project_Number='842'"}}
I had too many brackets in the response above. Just fixed it.