I am trying to build a .NET SOI that logs the username associated with each query, as well as the GlobalIds of all features contained in the response. The SOI works fine when the outputFormat is "json", however, the format used with many web clients is "pbf".
I managed to find the Esri/arcgis-pbf/tree/main/proto/FeatureCollection github repo and generate the FeatureCollection class to convert the byte[] output of IRESTRequestHandler.HandleRESTRequest to a JSON string using the following code:
byte[] originalResponse = restRequestHandler.HandleRESTRequest(Capabilities, resourceName, operationName, operationInput, outputFormat, requestProperties, out responseProperties);
string resultJSONStr = null;
if(outputFormat == "pbf") {
var featureCollection = FeatureCollectionPBuffer.Parser.ParseFrom(originalResponse);
resultJSONStr = JsonFormatter.Default.Format(featureCollection);
}
ESRI.Server.SOESupport.JsonObject resultJSON = new ESRI.Server.SOESupport.JsonObject(resultJSONStr);
However, the structure of this JsonObject is completely different than that of the one generated when the output format is json. It does not resemble an Esri feature collection at all.
Is anybody aware of a library to convert the PBF JsonObject into an array of features?