SampleServer6 - Feature Server Query returns empty list

839
3
Jump to solution
10-06-2022 04:25 AM
Ahmed_S
New Contributor II

Dear community, 

For a school project I need to make use of the Arcgis REST API. I was reading the documentation at this page and decided to try it out with sample server 6. Unfortunately i got this response:  

{
    "layers": []
}
 
 
Am I doing something wrong or is this just sampleserver 6? If it is sampleserver 6 should I just create my own server/features or are there any other public servers I can use to experiment with the API?
0 Kudos
1 Solution

Accepted Solutions
GeoJosh
Esri Regular Contributor

Ah you're right! My bad.

It looks like you need to specify query string for the "layerDefs" to get a response back. This worked for me:

https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/query?layerDefs=0...

The format is <layerID1>:<whereClause1>;<layerID2>:<whereClause2> and so on.

View solution in original post

3 Replies
GeoJosh
Esri Regular Contributor

Good morning! It appears you're trying to query the feature service instead of a specific feature layer within the service. To query a layer within the service, add the layer ID to the URL after /FeatureServer. So I think the URL you are actually looking for is this:

https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0/query?where=1=1...

You can get a list of all available layers in the service by going to the endpoint below and looking under "Layers".

https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer 

0 Kudos
Ahmed_S
New Contributor II

Hi, Thank you for your response!

Your link definitely works, but I was actually looking to get this response as shown in the documentation. The way it was shown in the documentation is that you can make a query directly on the service to get this response and not necessarily on the layer itself. 

0 Kudos
GeoJosh
Esri Regular Contributor

Ah you're right! My bad.

It looks like you need to specify query string for the "layerDefs" to get a response back. This worked for me:

https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/query?layerDefs=0...

The format is <layerID1>:<whereClause1>;<layerID2>:<whereClause2> and so on.