AnsweredAssumed Answered

Calling gp service from pure .NET

Question asked by modybsystematics-co-il-esridist Employee on Jun 2, 2016
Latest reply on Oct 24, 2016 by spring1990

Hello

 

I have a gp service I would like to call from .NET program that does not have any ESRI libreries.

This should be easy using the REST calls.

I followed Rex's blog here: http://rexdotnet.blogspot.co.il/2009/11/using-arcgis-server-rest-api-in-net.html

The example runs a geocoder and not gp service.

You can see my code below. The service is running, I get result but it is only include some metadata on the request like service name and version.

I should be able to get an event when the request is done and get the full results.

Anybody is doing it?

           string requestUri =
               "http://mody-pc:6080/arcgis/rest/services/RestCall/GPServer";
            
            StringBuilder data = new StringBuilder();
            data.AppendFormat("?f={0}", "json");
           data.AppendFormat("&str1={0}&str2={1}", System.Web.HttpUtility.UrlEncode(StreetTextBox.Text),
                System.Web.HttpUtility.UrlEncode(ZoneTextBox.Text));
            
            HttpWebRequest request = WebRequest.Create(requestUri + data) as HttpWebRequest;


            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());


                string responseString = reader.ReadToEnd();

Outcomes