arcgis server rest api, feature service,
if you query the layer, with URL like this, .../FeatureServer/query?layerDefs=...
http://services3.arcgis.com/your_token/arcgis/rest/services/Parcels/FeatureServer/query?layerDefs={"0":""}&returnGeometry=true&f=pgeojson&geometryType=esriGeometryEnvelope&geometry={"xmin" : -117.923158, "ymin" : 33.644081, "xmax" : -117.921436, "ymax" : 33.645157,"spatialReference" : {"wkid" : 4326}}
You can not set geojson format, f=pgeojson will be bad request, f=json, because the return stuff is not feature, the layers json was return.
Try this html query page, you can see, no geojson option,
http://services3.arcgis.com/you_token/arcgis/rest/services/Parcels/FeatureServer/query
If you want to return geojson (feature), you must use this URL .../FeatureServer/0/query...
/0/ means layerID, if on has only 1 layer, then layerID = 0.....
Try this html query page, you can see, geojson is option, because you are query specific layer with layerID = 0
http://services3.arcgis.com/your_token/arcgis/rest/services/Parcels/FeatureServer/0/query
Note: remember to set those 2 parameters: outSR=4326&f=geojson in the URL
spatial reference ID, srid = 4326, because web map all use this, f means format, both f=pgeojson and f=geojson works. If you don't set outSR=4326, arcgis server rest api by default will NOT use 4326, instead use something else, only 4326 has unit degree, which is used in most web map. Other format would not work with web maps.
By the way, for those want to use arcgis server rest api with tile service,
tilestream and others
/zoom(z)/x/y.png
http://localhost/v2/city_parcels/12/706/1641.png
arcgis server tile service: no png, x and y in different order
/zoom(z)/y/x
http://services3.arcgis.com/your_token/ArcGIS/rest/services/Parcels/MapServer/tile/12/1641/706