POST query to ArcGIS rest api ignores query criteria in request content body

المشرف العام

Administrator
طاقم الإدارة
This is representative of what I'm trying to do. The query criteria may be too long for a url so I want to post it.

I'm abbreviating the sb building code for brevity. If I append the sb variable to the url I get the correct data back on a test query, so I know that part of the code is ok.

If I don't append the sb value to the url, I get a query page back that goes with the parameterless url, not the data in json format. It's as if the query criteria in the request content body is not being recognized or used.

private static string QueryHighways(string baseUrl, int layerID) { string url = String.Format("{0}/{1}/query", baseUrl, layerID); var wc = new WebClient(); wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); StringBuilder sb = new StringBuilder(); sb.Append("&inSR=&spatialRel=esriSpatialRelIntersects"); sb.Append("&where="); // etc., etc... sb.Append("&f=pjson"); var bytes = Encoding.ASCII.GetBytes(sb.ToString()); var respBytes = wc.UploadData(url, "POST", bytes); return Encoding.ASCII.GetString(respBytes); }

أكثر...
 
أعلى