I am performing a QueryFeaturesAsync on a ServiceFeatureTable which is configured with the url https://geo.abs.gov.au/arcgis/rest/services/ASGS2021/SA4/MapServer/0
It works fine, except when I have 'large' geometries, e.g. a polygon >12 points in it, I get a 403 (Forbidden) error. I think this is their way of telling me that my GET request is too long. I think the underlying data transferred is JSON, and it seems to have 20+ significant figures in each coordinate. I'm only guessing that ServiceFeatureTable always uses GET. If true, how can I force it to do a POST, which doesn't have size limits?
Solved! Go to Solution.
Have you also tried running the query in a browser?
e.g. Query: SA4 (ID: 0) (abs.gov.au)
For `Where`, if you enter 1=1 then click:
Query (GET): I get the query response (after some time).
Query (POST): I get a 403 - could there be a server-side issue with POST requests?
Regarding ArcGIS Runtime, the API will automatically switch internally from GET to POST when the URI length requires it.
A couple of options for diagnosing these types of issues:
ArcGISHttpClientHandler.HttpRequestBegin += (sender, httpRequestMessage) =>
{
Debug.WriteLine(httpRequestMessage.Method);
};
Have you also tried running the query in a browser?
e.g. Query: SA4 (ID: 0) (abs.gov.au)
For `Where`, if you enter 1=1 then click:
Query (GET): I get the query response (after some time).
Query (POST): I get a 403 - could there be a server-side issue with POST requests?
Regarding ArcGIS Runtime, the API will automatically switch internally from GET to POST when the URI length requires it.
A couple of options for diagnosing these types of issues:
ArcGISHttpClientHandler.HttpRequestBegin += (sender, httpRequestMessage) =>
{
Debug.WriteLine(httpRequestMessage.Method);
};
Very interesting. I had previously used Wireshark to eavesdrop on the signalling with the ArcGis server. It was exclusively TCP and TLS packets (no HTTP). It was either encrypted or compressed, so I could make no sense of it.
Your adding an EventHandler techinque worked very well. I built a small debug tool to display Request and Response (output below). It confirms that small geometries use GET whilst large ones use POST. The debug trace below is from a large geometry. There is an initial GET (OK) and then a POST. This POST returns a 403 (Forbidden). I have noticed this behaviour even on the interactive interface to this service. I wrote to the owner about POST's not working about 3 weeks ago, and I've heard nothing. I'm 3 for nothing with this service owner 😞
I think the situation is that POST is either disabled or broken for this service, and I will have to settle for the low resolution GET method.
Request -------------------------------------------------------
RequestUri https://geo.abs.gov.au/arcgis/rest/services/ASGS2021/SA4/MapServer/0?f=json&returnAdvancedSymbols=tr...
Method GET
Headers User-Agent: ArcGISRuntime-NET/100.15 (Windows 10.0.19044; Win64; .NET6.0.9; devmode)
Referer: http://arcgis.com/
Response -------------------------------------------------------
StatusCode OK
Headers Connection: keep-alive
Date: Mon, 10 Oct 2022 23:39:15 GMT
Cache-Control: public, must-revalidate, max-age=0
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
ETag: 4c0a51b
X-Cache: Miss from cloudfront
Via: 1.1 1147e5ecd1f71df7e8584b06e2b9be6e.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: MEL50-C2
X-Amz-Cf-Id: KujWL3Yg1ANDY1AHHGAOD9XGBFLbYNHcozUWiu1SeAdLqYzF7aXBvA==
X-Frame-Options: SAMEORIGIN
Referrer-Policy: strict-origin-when-cross-origin
Vary: Origin
Content Esri.ArcGISRuntime.Http.Caching.CachedHttpContent
Request -------------------------------------------------------
RequestUri https://geo.abs.gov.au/arcgis/rest/services/ASGS2021/SA4/MapServer/0/query
Method POST
Headers User-Agent: ArcGISRuntime-NET/100.15 (Windows 10.0.19044; Win64; .NET6.0.9; devmode)
Referer: http://arcgis.com/
Content Esri.ArcGISRuntime.Internal.FormUrlEncodedContentInternal
Response -------------------------------------------------------
StatusCode Forbidden
Headers Connection: close
x-amz-server-side-encryption: AES256
x-amz-version-id: I0lDqCgoP.EIelhfhEuNnZJ8_KSrgDgD
Accept-Ranges: bytes
Server: AmazonS3
Date: Mon, 10 Oct 2022 23:39:16 GMT
ETag: "4963e19fd3d3ca2d1ce8666a11085544"
X-Cache: Error from cloudfront
Via: 1.1 1147e5ecd1f71df7e8584b06e2b9be6e.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: MEL50-C2
X-Amz-Cf-Id: 4vWyHXEzyVP-6JcMgV_mN81Al3UepR3w0zMVKL2TxBRaE8Srr0IGNA==
Content System.Net.Http.HttpConnectionResponseContent