I am attempting to query data that has been loaded into ArcGIS in the form of layers.

I am attempting to query out basic data (Any data at this point) from a imported Layer. I think the error is with my .Net code and how I set up to attempt the query but I seem to run into errors when I attempt to query data that is present in the tutorial.

Code Below:

        public async static Task QuerySantaAnaData()
        string tokenString = ""; //This is generated on the the Dashboard for ArcGIS for Developers page under Temporay Access Token

        string path = @"https://services3.arcgis.com/{My ID}/ArcGIS/rest/services/{Service Name}/FeatureServer/0/query?where=FID>0&outFields=*";
            using (HttpClient client = new HttpClient())
                client.Timeout = new TimeSpan(0, 1, 0, 0);
                client.DefaultRequestHeaders.Add("Token", tokenString);

                using (HttpResponseMessage response = await client.GetAsync(path))
                    using (HttpContent content = response.Content)
                        string data = await content.ReadAsStringAsync();

        catch (Exception e)


The Inner Exception I receive is

{System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)}

I have even attempted to perform this API request with the example data that ArcGIS provides in their tutorials here https://developers.arcgis.com/labs/rest/query-a-feature-layer/


Try sending your token in the URL query params (string path = @"https://services3.arcgis.com/{My ID}/ArcGIS/rest/services/{Service Name}/FeatureServer/0/query?where=FID>0&outFields=*&token=______";) instead of in the headers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.