Calling gp service from pure .NET

06-02-2016 03:11 AM
Esri Regular Contributor


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:

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 =
            StringBuilder data = new StringBuilder();
            data.AppendFormat("?f={0}", "json");
           data.AppendFormat("&str1={0}&str2={1}", System.Web.HttpUtility.UrlEncode(StreetTextBox.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();
0 Kudos
1 Reply
New Contributor II

Hi Mody, have you figured it out?

0 Kudos