I'm attempting to call the geocodeAddresses method in the ArcGIS REST API in my C# application. The "addresses" input parameter is a potentially very long JSON string containing an array of a complex type. The code below works ok and I get a response from the API if the addresses param is a short JSON string containing only a few addresses, but if it is a very long string with many addresses I get an "Invalid URI: The Uri string is too long." exception when PostAsync() is called. So what I'm doing is just calling the API with a long url. How can I ensure the parameters are posted to the body of the request and not get an extremely long url?
</CODE></P><P><SPAN style="font-family: 'courier new', courier;"><CODE>string url = "<A href="http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/geocodeAddresses" title="http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/geocodeAddresses" rel="nofollow noopener noreferrer">http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/geocodeAddresses</A> ";<BR />var values = new Dictionary<string, string><BR />{<BR /> {"token", token},<BR /> {"forStorage", "true"},<BR /> {"MaxBatchSize", "1000"},<BR /> {"outFields", "*"},<BR /> {"f", "json"},<BR /> {"addresses", inputJson} //inputJson is an array of a complex type<BR />};<BR /><BR />using (var client = new HttpClient())<BR />{<BR /> try<BR /> {<BR /> var content = new FormUrlEncodedContent(values);<BR /> var response = await client.PostAsync(url, content);<BR /> Task<string> responseString = response.Content.ReadAsStringAsync();<BR /> string outputJson = await responseString;<BR /> res = JsonConvert.DeserializeObject<DoStuffResult>(outputJson);<BR /> }<BR /> catch (Exception ex)<BR /> {<BR /> Debug.WriteLine(ex.ToString()); //"Invalid URI: The Uri string is too long."<BR /> } <BR />}