Select to view content in your preferred language

Basic REST API Query Question

685
3
Jump to solution
04-24-2012 07:02 AM
JayGregory
New Contributor III
I'm pretty new to the REST API (having played around with the JavaScript API a good bit though) -
I'm curious what are the constraints on varies queries...
For instance, if I want the json returned for an entire map service layer

http://win-2rninrlf7l8/ArcGIS/rest/services/FSDO_NoSDE/MapServer/0/query?f=json
doesn't seem to work.  I have to include a WHERE parameter to narrow the search.

When I try to return _everything_ I get an error that says...

"where' parameter not specified","'objectIds' parameter not specified","'time' parameter not specified","'geometry' parameter not specified","'text' parameter not specified"

Are the above parameters necessary to narrow the number of results that could potentially be returned?
Is there any way to just return _all_ of the features + geometry in a map service layer?

Thanks for your help!
0 Kudos
1 Solution

Accepted Solutions
JMcNeil
Occasional Contributor III
In C# I would write it like this:

// Return all features
query.Where = "1=1";


If I was hitting the rest endpoint directly...lets use this rest for an example


http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5/...


in the where box I would enter

1=1

Select JSON - Hit the Query(get) button and you will get all records returned.

Jay

View solution in original post

0 Kudos
3 Replies
RobWaller
New Contributor III
How are you returning everything with WHERE.
For example in a state layer if I use this in WHERE it works for me:
STATE_NAME LIKE '%'

Here's full url using ESRI sample server, the WHERE will be HTML encoded:

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5/query?text=&geometry=&geometryType=esriGeometryPoint&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=STATE_NAME+LIKE+%27%25%27&time=&returnCountOnly=false&returnIdsOnly=false&returnGeometry=true&maxAllowableOffset=&outSR=&outFields=&f=pjson


Maybe a better way but this seems to work
0 Kudos
JMcNeil
Occasional Contributor III
In C# I would write it like this:

// Return all features
query.Where = "1=1";


If I was hitting the rest endpoint directly...lets use this rest for an example


http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5/...


in the where box I would enter

1=1

Select JSON - Hit the Query(get) button and you will get all records returned.

Jay
0 Kudos
JayGregory
New Contributor III
Thanks all - that worked.  I just wasn't sure what parameters were required for the query to work.
0 Kudos