Select to view content in your preferred language

How to call a map service passing parameters in the where field

66
2
yesterday
JoseSanchez
Regular Contributor

Good morning,

I am looking for a way to call a  layer in an ArcGIS Server map service passing parameters in the where  clause

 https://[ArcgIS Server]/arcgis/rest/services/[My Map Service/FeatureServer/1

I would like call this service passing a parameter such as ProjectID = 1 or ProjectID = 2

How can I do that?

0 Kudos
2 Replies
EricAnderson_DHS
Occasional Contributor

What I find helpful is adding the service to a map viewer in AGOL/Portal, create a filter using the query parameters you want, and then use the browser's Developer Tools to see exactly how the query/WHERE clause was structured. 

 

https://<machine.domain>/<WA>/rest/services/Hosted/<name>/FeatureServer/0/query?f=json&where=(projectid = 1) OR (projectid = 2)

0 Kudos
jcarlson
MVP Esteemed Contributor

The REST API docs have all the details. @EricAnderson_DHS 's answer is great, I would only add that you want to encode your parameters to get a URL string.

…/FeatureServer/1/query?where=(ProjectID%3D1)+or+(ProjectID%3D2)

Where are you calling this layer from, by the way?

- Josh Carlson
Kendall County GIS
0 Kudos