I have a standalone table in an ArcGIS rest service that I need to query. The service has security requiring a username and password. I used this table in 10.2.6 applications using credentials and querytask without a problem. Is there a way in runtime to query this table? Do I have to use NetworkRequest, which is more complicated with tokens?
You can do that with a ServiceFeatureTable. This sample showcases this with a feature layer for viewing, but you don't need to display it - you could just query the ServiceFeatureTable directly - arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Features/FeatureLayer_Query at master · Esri...
As for the authorization component, you can do that a few ways. You can create a Credential object with username and password, and set that on the ServiceFeatureTable. You could also use the AuthenticationManager workflow, which is discussed here - Access the ArcGIS platform—ArcGIS Runtime SDK for Qt | ArcGIS for Developers
Hi Lucas,
That was the first thing I tried and apparently since the table has no geometry that doesn't work.
Tables with no geometry should work. Here is an example:
import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISRuntime 100.6
ApplicationWindow {
id: appWindow
width: 800
height: 600
title: "Untitled81"
ServiceFeatureTable {
url: "https://services2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/rest/services/AlaskaNationalParksPreservesSpecies_List/FeatureServer/2"
Component.onCompleted: {
load()
}
onLoadStatusChanged: {
if (loadStatus === Enums.LoadStatusLoaded) {
console.log("loaded");
queryFeatures(params);
}
}
onQueryFeaturesStatusChanged: {
if (queryFeaturesStatus === Enums.TaskStatusCompleted) {
console.log("complete");
let iter = queryFeaturesResult.iterator;
while (iter.hasNext) {
var feat = iter.next();
console.log(JSON.stringify(feat.attributes.attributesJson))
}
}
}
}
QueryParameters {
id: params
whereClause: "1=1"
}
}
The service in the example you provided the table has an objectid. Ours does not and that may cause problems.
Here is the error.
qml: Suggest like '%2%' and LayerField like 'Parcels-Site_Address'
ArcGIS.AppFramework.Player: Object: QObject(0x0) Text: "file:///C:/Users/huntj/ArcGIS/AppStudio/Apps/6154a8cf097142b38e223b3d9abc999d/MonTopo2.qml:351: TypeError: Cannot read property 'iterator' of null"
file:///C:/Users/huntj/ArcGIS/AppStudio/Apps/6154a8cf097142b38e223b3d9abc999d/MonTopo2.qml:351: TypeError: Cannot read property 'iterator' of null
Hi Lucas,
I got it. I made a typo which caused the error.
Thanks