I'm trying to get a simple list of fields from an ArcGIS Online Hosted feature service.
When I paste the local service url into a web browser, I get back a JSON string that includes the fields.
https://***.*******.com/intgis3/rest/services/FCC/fcc_zones/MapServer/0/fields?f=json
when I tried the same thing with the AGOL hosted FeatureService, and included a token I got back this error {"error":{"code":400,"message":"Error: Feature (ID: fields) not found","details":["Unable to retrieve feature."]}}
I tried with POST and a simple webClient.DownloadString(). Once again that worked for my local service but not the AGOL service.
how can I get just a list of fields of hosted feature service?
I'm going to do a /query with fields="*" and manipulate that. But it sure would be easier if this worked in AGOL
my local ArcGIS Server is 10.71
Solved! Go to Solution.
Hosted feature layers are FeatureServer items. Normally, a slash after the layer index is for returning information about a specific feature. For instance, FeatureServer/0/2 would give me the details for the feature with the objectid 2. So your URL is telling it to look for "fields" as an ID.
A call to /FeatureServer/0?f=json ought to return the same JSON string. I don't think there actually is a "/fields" URL.
Hosted feature layers are FeatureServer items. Normally, a slash after the layer index is for returning information about a specific feature. For instance, FeatureServer/0/2 would give me the details for the feature with the objectid 2. So your URL is telling it to look for "fields" as an ID.
A call to /FeatureServer/0?f=json ought to return the same JSON string. I don't think there actually is a "/fields" URL.
Just as I had finished doing a query where 1=1 and parsing out the fields from that JSON, I see your response. It worked as expected.
This is the third time I got stuck trying to move from AGS 10.71 to AGOL. It just frustrated me that the /fields works in AGS and not AGOL.
Thank you for the timely response. Now I can call it a day and go play some golf!