Tuesday, August 20, 2019

Code snippet: HTTP call to ArcGIS server from ArcGIS Runtime Enviroment 100.x

Required namespaces - 

using System.Net.Http;
using Esri.ArcGISRuntime.Http;

using Newtonsoft.Json; //To parse the response

Code snippet - 

Uri requestUri = new Uri(serviceUrl +"?f=pjson");

//Default HttpClient handler which also handles the ArcGIS server Identity
ArcGISHttpClientHandler handler = new ArcGISHttpClientHandler() 
                                                                  { UseDefaultCredentials = true };

HttpClient client = new HttpClient(handler);

string serverResponseJsonString = await client.GetStringAsync(requestUri);

Console.WriteLine(serverResponseJsonString );  

//Convert respones string to JSON Object, optional
ArcGisServerResponse  serverResponseJson = JsonConvert.DeserializeObject<ArcGisServerResponse>(serverResponseJsonString);

ArcGIS Runtime


Post a Comment


© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me