Trouble getting minimum value from FeatureTable

186
4
12-18-2018 08:45 AM
KeithLarson1
MVP

Hello all,

I am trying to get the minimum value in a table in a FeatureServer. I have tried both the queryStatistics method and using a NetworkRequest object with outStatistics set.

For the queryStatistics problem, I am creating a StatisticsQueryParametes object with a StatisticDefinition specifying the field that I want and that the statisticType should be Enums.StatisticTypeMinimum. I connect a function to the queryStatisticsStatusChanged signal and I see when it is chaned to in progress. However, after a bit of time, I get the error: QObject::connect: Cannot queue arguments of type 'std::shared_ptr<QRTImpl::Stati

sticsQueryResultImpl>' (Make sure 'std::shared_ptr<QRTImpl::StatisticsQueryResultImpl>' is registered using qRegisterMetaType().). 

When I tried using a NetworkRequest object, I send the message: {f: "json", outStatistics: [{"statisticType":"min","onStatisticField":"myId", "outStatisticFieldName":"MinID"}]}. The response object gives me the error code 400. I know statistics querying is enabled on this table, because if I go to the query page in my web browser I can put in the same json that I'm setting to outStatistics and I get the result with no problem.

If anyone knows what I'm doing wrong, the help would be greatly appreciated.

Thanks,

Keith

0 Kudos
4 Replies
ErwinSoekianto
Esri Regular Contributor

Keith, 

That is weird, technically you should be getting the same result when making the REST request and NetworkRequest. 

Can you show us your NetworkRequest component code? There is a possibility that you may be missing some parameters when sending the request that's causing it to return error 400 instead. 

Thank you, 

Erwin.

0 Kudos
KeithLarson1
MVP

This is my NetworkRequest object where I'm just printing out the response:

NetworkRequest {
   id: getMinID
   url: featureServiceUrl
   responseType: "json"
   method: "POST"
   onReadyStateChanged: {
       if (readyState === NetworkRequest.DONE) {
          console.log("Response: " + JSON.stringify(response));
       }
   }
}

And, here is the request I send:

getMinID.send({f: "json", outStatistics: [{"statisticType":"min","onStatisticField":"myId", "outStatisticFieldName":"MinID"}]});
0 Kudos
ErwinSoekianto
Esri Regular Contributor

Did you make sure that the "featureServiceUrl" has the layer id and query operation? 

like this: https://<featureServiceURL>/FeatureServer/0/query

0 Kudos
KeithLarson1
MVP

I printed the url and it had the form http://<featureServiceURL>/FeatureServer/2/query which is the correct table as well. I get the response: {"error":{"code":400,"details":["Unable to perform query operation."],"message":"Unable to complete operation."}}

0 Kudos