ArcGIS Runtime .Net 100.6 - Dynamic Layer Query/Edit

170
3
10-31-2019 05:35 PM
Highlighted
New Contributor

I am using ArcGIS runtime sdk for .net 100.6.

I start a localserver and load a map service from mpk file.

I add a filegeodatabase as dynamic workspace to the map service and add a ArcGISMapImageSubLayer created from a TableSubLayerSource to the map service first ArcGISImageSubLayer.

I am getting an exception while executing ServiceFeatureTable.QueryFeaturesAsync

Code

string uri = string.Format(
"{0}?layer={{'id':{1}, 'source' :{{'type' : 'dataLayer', 'dataSource' : {{'type':'table', 'workspaceId':'{2}', 'dataSourceName' : '{3}', 'gdbVersion':''}}, 'mapLayerId' : {1} }}}}",
nodesLayer.MapServiceSublayerInfo.Source.AbsoluteUri,
nodesLayer.Id, ((TableSublayerSource) nodesLayer.Source).WorkspaceId,
((TableSublayerSource) nodesLayer.Source).DataSourceName);

ServiceFeatureTable newTable = new ServiceFeatureTable(new Uri(uri));

QueryParameters queryParams = new QueryParameters();
queryParams.WhereClause = "OBJECTID > 1";
queryParams.ReturnGeometry = true;
queryParams.OutSpatialReference = mapView.SpatialReference;

FeatureQueryResult queryResult = await newTable.QueryFeaturesAsync(queryParams);

I am getting an exception Invalid or missing input parameters.

1. What am I doing wrong?

2. Can I edit features in a dynamicLayer?

Thanks

Reply
0 Kudos
3 Replies
Highlighted
Esri Frequent Contributor

Hi,

Unfortunately the DynamicLayer capability is not supported on the FeatureServer endpoint.

To edit data, it should be within a mobile geodatabase taken offline from a service. For smaller scale local editing, FeatureCollections, Shapefiles and Geopackages are supported as well.

Regards

Mike

Reply
0 Kudos
Highlighted
New Contributor

Thank you Michael for clarifying my doubt about editing dynamic layers using ArcGIS runtime SDK 100.6

I am still unable to run QueryFeaturesAsync against the dynamic layer, I keep getting the error "Invalid or missing input parameters".

1. What parameter is invalid?

2. What are the missing input parameters?

 

 

This is the service url for the ServiceFeatureTable

string url = "http://127.0.0.1:50000/arcgis/rest/services/mpk_blank/MapServer/dynamicLayer?layer={'id':101, 'source' :{'type' : 'dataLayer', 'fields' : [{'name':'OBJECTID' ,'alias':'OBJECTID'},{'name':'nodetype' ,'alias':'nodetype'}], 'dataSource' : {'type':'table', 'workspaceId':'myDb', 'dataSourceName' : 'nodes', 'gdbVersion':''} }}";

// the dynamic layer points to a table source referencing a file geodatabase (.gdb) table)

 

ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(new Uri(url));

serviceFeatureTable.LoadStatusChanged += async (k, h) =>
{

      if (h.Status == LoadStatus.Loaded)
      {               
            try

            {
                        QueryParameters qryParams = new QueryParameters();
                        qryParams.WhereClause = "OBJECTID > 0";
                        qryParams.ReturnGeometry = true;

                        qryParams.SpatialReference = MyMapView.Map.SpatialReference; // both the feature class in file gdb and map have the same spatial reference
                        qryParams.MaxFeatures = 100;
                        qryParams.OrderByFields.Add(new OrderBy("OBJECTID", SortOrder.Ascending));
                        qryParams.ResultOffset = 0;
                        qryParams.SpatialRelationship = SpatialRelationship.Intersects;
                        ServiceFeatureTable stbl = k as ServiceFeatureTable;
                        FeatureQueryResult features = await stbl.QueryFeaturesAsync(qryParams);

                        int count = features.Count();            

            }

            catch (Exception gex)
            {            
                   string genmsg = gex.Message; // Invalid or missing input parameters

                    // gex.JsonResponse {"error":{"code":400,"message":"Invalid or missing input parameters.","details":[]}} 

                    // why????
             }

      }
};

await serviceFeatureTable.LoadAsync();

 

 

the QueryFeaturesAsync fails. The exception details are incomplete, cannot determine what is wrong with the service uri or the query parameters.

Ex

JsonResponse : {"error":{"code":400,"message":"Invalid or missing input parameters.","details":[]}}

Reply
0 Kudos
Highlighted
Esri Frequent Contributor

Hi Keith,

I recommend monitoring the traffic in using a web debugging tool (e.g. Fiddler). To enable capturing http traffic, see the section on the `Local Server Utility` in the Local Server—ArcGIS Runtime SDK for .NET | ArcGIS for Developers topic.

Because this query is hitting the MapServer/DynamicLayer endpoint, the relevant REST doc is Query (Map Service/Dynamic Layer)—ArcGIS REST API: Services Directory | ArcGIS for Developers

Cheers

Mike

Reply
0 Kudos