How do I obtain a list of all fields in a web service?

765
2
Jump to solution
02-18-2014 06:36 AM
DonaldCatanzaro
New Contributor III
Hi All,

I think this is an easy question but I cannot seem to find an API call that can return the list of fields in an ArcGIS web service. 

For instance, this webhttp://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Median_Household_Income/MapServ...

has the following fields:
[INDENT]OBJECTID
Shape
ID
NAME
ST_ABBREV
LANDAREA
TOTPOP_CY
MEDHINC_CY
HINCBASECY
HINC50_CY
HINC75_CY
HINC100_CY
HINC150_CY
HINC200_CY
MEDHHINC_pct_USAvg
HINC0_25
HINC35_50[/INDENT]

I basically want to be able to consume (dynamically) this list so I can put it into my UI.

Thank you in advance !
0 Kudos
1 Solution

Accepted Solutions
RobertoPepato
Occasional Contributor II
Hi All,

I think this is an easy question but I cannot seem to find an API call that can return the list of fields in an ArcGIS web service. 

For instance, this webhttp://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Median_Household_Income/MapServ...

has the following fields:
[INDENT]OBJECTID
Shape
ID
NAME
ST_ABBREV
LANDAREA
TOTPOP_CY
MEDHINC_CY
HINCBASECY
HINC50_CY
HINC75_CY
HINC100_CY
HINC150_CY
HINC200_CY
MEDHHINC_pct_USAvg
HINC0_25
HINC35_50[/INDENT]

I basically want to be able to consume (dynamically) this list so I can put it into my UI.

Thank you in advance !


You need to specify from which layer you're interested in. A map service is a composition of many layers, each of them with a field set. You can access a specific layer from a MapService using and index based identifier in your url, like the following sample:


http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Median_Household_Income/MapServer/1


You can query the fields of a specific layer using the property fields of a FeatureService object. See this link for more info.

View solution in original post

0 Kudos
2 Replies
RobertoPepato
Occasional Contributor II
Hi All,

I think this is an easy question but I cannot seem to find an API call that can return the list of fields in an ArcGIS web service. 

For instance, this webhttp://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Median_Household_Income/MapServ...

has the following fields:
[INDENT]OBJECTID
Shape
ID
NAME
ST_ABBREV
LANDAREA
TOTPOP_CY
MEDHINC_CY
HINCBASECY
HINC50_CY
HINC75_CY
HINC100_CY
HINC150_CY
HINC200_CY
MEDHHINC_pct_USAvg
HINC0_25
HINC35_50[/INDENT]

I basically want to be able to consume (dynamically) this list so I can put it into my UI.

Thank you in advance !


You need to specify from which layer you're interested in. A map service is a composition of many layers, each of them with a field set. You can access a specific layer from a MapService using and index based identifier in your url, like the following sample:


http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Median_Household_Income/MapServer/1


You can query the fields of a specific layer using the property fields of a FeatureService object. See this link for more info.
0 Kudos
KellyHutchins
Esri Frequent Contributor
pepatosp is correct - you need to query for the individual layer.   Here's a link to a sample in the help that shows how to do this:

https://developers.arcgis.com/javascript/jssamples/data_requestLayerInfo.html
0 Kudos