Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8262585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:48:07+00:00 2026-06-08T03:48:07+00:00

I am working on an app to iterate through a list of zip codes

  • 0

I am working on an app to iterate through a list of zip codes and business types that will then create a call to the Google Places API (Text Search) via a url that I construct for those parameters.

The url will look something like this

https://maps.googleapis.com/maps/api/place/textsearch/json?key=MY_API_KEY_HERE&sensor=false&query=57783+dentist

The function below is called for each of these requests:

    private static StreamReader MakeWebRequest(string sURL)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sURL);
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream responseStream = response.GetResponseStream();
        StreamReader objReader = new StreamReader(responseStream);
        return objReader;
    }

The problem I am experiencing is that, after 3 to 5 iterations, the response object times out (System.Net.WebException = “The operation has timed out”). My first thought was that the requests were being sent to quickly, so I inserted a Sleep(2000) in the loop, but this seems to have no effect. I have checked the urls that are failing and pasted them into a browser and they do return the proper data.

As I understand it, the only limitation to calls on this api are the 1000 per day I get with an unverified account. What am I missing?

EDIT: Here is the rest of the program block:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using GooglePlacesJSONGenerator.Models;

namespace GooglePlacesJSONGenerator
{
class Program
{
    static void Main(string[] args)
    {
        //set up a list of zips
        List<string> zipcodeList = new List<string>();
        zipcodeList.Add("57754");
        zipcodeList.Add("57783");
        zipcodeList.Add("57785");

        //setup a list of business types
        List<string> businessTypeList = new List<string>();
        businessTypeList.Add("restaurants");
        businessTypeList.Add("dentist");
        businessTypeList.Add("gym");

        //main data set
        GooglePlaceDataSet places = new GooglePlaceDataSet();

        //base url
        string urlBase = "https://maps.googleapis.com/maps/api/place/textsearch/json?key=MY_API_KEY_HERE&sensor=false&query=";
        string nextUrlBase = urlBase + "&pagetoken=";
        Stream objStream;
        //loop on zip codes
        foreach (string zip in zipcodeList)
        {
            Console.WriteLine("looping on zip " + zip);

            //loop on business type
            foreach (string type in businessTypeList)
            {
                Console.WriteLine("loop on type " + type);

                string sURL;
                string query = HttpUtility.UrlEncode(zip + " " + type);
                sURL = urlBase + query;
                Console.WriteLine("Query String: " + query);
                while (sURL != "")
                {

                    Console.WriteLine("Our URL:  " + sURL);
                    Console.WriteLine("");

                    StreamReader objReader = MakeWebRequest(sURL);

                    JsonTextReader reader = new JsonTextReader(objReader);

                    JsonSerializer se = new JsonSerializer();
                    string parsedData = se.Deserialize(reader).ToString();
                    GooglePlaceDataSet gSet = JsonConvert.DeserializeObject<GooglePlaceDataSet>(parsedData);

                    foreach (GooglePlaceData place in gSet.results)
                    {
                        places.results.Add(place);
                    }

                    if (gSet.next_page_token != null)
                        sURL = nextUrlBase + gSet.next_page_token;
                    else
                    sURL = "";

                    System.Threading.Thread.Sleep(2000);
                }
            }
        }
        Console.ReadLine();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:48:09+00:00Added an answer on June 8, 2026 at 3:48 am

    The answer was “don’t forget the obvious.” The StreamReader object needed to be closed. Once I closed it, the above code worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I working for an app that requires google login. I need to access provider_uid,
I am working on App which will set an alarm on ios for a
I've been working with app engine for quite some time, I know that there
I've got a nice little web app working that brings down playlists and videos
I did heroku create and pushed a working rails app to the server. Everything
I'm working on a utility web app that to help manipulate some domain-specific XML
I've got a working app that saves a document into a user-specified folder in
I am working on an iPad app using appcelarator titanium and need to iterate
I am currently working on an app that allows for free-drawing. The current method
I'm working on an app that is reading it's data from a customized RSS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.