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);


Comments

Popular posts from this blog

Prevent WPF Global Keyboard Hook from stops working after hitting keys a while C# .NET

Generate ArcGIS Token By URL Request From ArcGIS Portal, Federated Environment , ESRI JS API and Angular snippets

Solution: IntelliJ not recognizing a particular file correctly, instead its stuck as a text file