Select to view content in your preferred language

FeatureSet.ToJson() Bug

665
1
02-15-2011 01:14 PM
RyanCooney
Occasional Contributor
The method is very useful, but it fails if there is no geometry in the FeatureSet.

            QueryTask task = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/TaxParcel/AssessorsLiveLayers/MapServer/1");
            Query query = new Query();
            query.Where = "OBJECTID=2";
            query.ReturnGeometry = false;
            FeatureSet features = task.Execute(query);
            string json = features.ToJson();


Throws:
System.ArgumentException : Unsupported geometry type
at ESRI.ArcGIS.Client.Tasks.Utils.JSON.ArcGISJsonWriter.GeometryToJson(Geometry geometry, Boolean includeGeometryType, Boolean includeSpatialReference)
at ESRI.ArcGIS.Client.Tasks.FeatureSet.ToJson(Boolean includeGeometryInJson)
at ESRI.ArcGIS.Client.Tasks.FeatureSet.ToJson()
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
Thank you for reporting this. We will include a fix in the future release of our API.

For the meantime, before calling ToJson(), ensure that there are no null geometries.
0 Kudos