I am trying to query and ArcGIS rest endpoint and copy it's features to a locally hosted feature class. My request gives me code [200] indicating that it successfully retrieves the rest end point, but when I write my data to a json file there is no data.
Here is my request code:
#Get data from rest service
params = {'where':'1=1','outFields':'*','f':'json','returnGeometry': True, 'geometryType':'esriGeometryPolygon'}
r = requests.get("url",params)
#Check results of get request
print(r)
data = r.json()
#save JSON to disc
with open("json file path",'w') as f:
json.dump(data, f)
#Copy json data to feature class
arcpy.JSONToFeatures_conversion("json file path", "feature class")
This is the rest endpoint I am trying to download from: https://gis.cachecounty.org/arcgis/rest/services/BaseMap/Parcels_Current/FeatureServer/query
The URL you are using is pointing the service, not the layer. Add the layer ID to the URL and your code should work.
For example:
https://gis.cachecounty.org/arcgis/rest/services/BaseMap/Parcels_Current/FeatureServer/0/query
Note the /0/ before the query
part, which points to the "Cache Parcels" layer.