Xamarin iOS SDK QueryFeaturesAsync JSON Exception

946
2
07-02-2017 06:10 PM
JasonVan_der_Meer
New Contributor

I am hitting an exception when trying to execute the "QueryFeaturesAsync" with a query parameter of Polygon Geometry. 

SDK Version: 100.1

Exception: "\"invalid start of json - expecting { or [\": < : 0"

I have tried the query with multiple different URI's and still hitting the same exception. When executing the query direct from the service (not through the SDK), I get a successful response with the data I expect.

Here is some of the code:

var featureTable = new ServiceFeatureTable(uri);

var queryParams = new QueryParameters();

queryParams.Geometry = geometry;

task = featureTable.QueryFeaturesAsync(queryParams);

try {

   await task;

}

catch(Exception ex)

{

   //expection occurs here

   Console.WriteLine("Failed to complete query" + e.ToString());

}

0 Kudos
2 Replies
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Jason, 

I just tested with a swift version of the code for queryFeature with AGSServiceFeatureTable and I do not reproduce this issue. 

Here is the snippet code that I used and you can try to use this service end point to test as well:

    private let FEATURE_SERVICE_URL = 
"http://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer/0"
    
    var map:AGSMap!
    var ft: AGSServiceFeatureTable!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //create an instance of a map with ESRI topographic basemap
        self.map = AGSMap(basemap: AGSBasemap.topographic())
        
        self.mapView.map = self.map
        
        queryTest()
    }

    
    func queryTest() {
        
        self.ft = AGSServiceFeatureTable(url:URL(string: FEATURE_SERVICE_URL)!);
        let queryParams = AGSQueryParameters()
        queryParams.whereClause = "has_pool = 1"
        
        self.ft.queryFeatures(with: queryParams) { (result: AGSFeatureQueryResult?, error: Error?) in
            if let error = error {
                print(error.localizedDescription)
            }
            else if let features = result?.featureEnumerator().allObjects {
                if features.count > 0 {
                    print(features)
                } else {
                    print("no feature")
                }
            }
        }
    
    }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Based on our 100.1 SDK doc:

ArcGIS Runtime SDK for iOS: AGSServiceFeatureTable Class Reference 

I do not think we have any function called "QueryFeaturesAsync", I wonder how do you implement?

Here I would recommend check this sample code that using Objective-c to work with queryFeaturesWithParameters: 

arcgis-runtime-samples-ios/RootViewController.m at 10.2.5-to-quartz · Esri/arcgis-runtime-samples-io... 

Another good suggestion is use Charles Web Debugging Proxy to investigate what's the request that you send and you can get more info from there. 

0 Kudos
JasonVan_der_Meer
New Contributor

Apologies, I forgot to specify that I am using the Xamarin iOS SDK. Hence why the code is c#. Here is a reference to the "QueryFeaturesAsync" method:

FeatureTable.QueryFeaturesAsync Method (QueryParameters) 


0 Kudos