dropOffLocations data

54 views
Skip to first unread message

Stephan Cloitre

unread,
Oct 6, 2020, 9:14:02 AM10/6/20
to Google Civic Information API
I see here that Drop Boxes data for California data is live, but when I query the api using the following request https://www.googleapis.com/civicinfo/v2/voterinfo?electionId=7000&address=' + address + '&key=<My Key>, it doesn't return anything for dropOffLocations[0].name, for example. 

I get this error message: TypeError: Cannot read property '0' of undefined (line 23, file "Code")

Here's the code. Line 23 is the one that includes dropOffLocations[0].name

 address = '3015 SACRAMENTO AVE ACTON,CA 935100';
   var request = 'https://www.googleapis.com/civicinfo/v2/voterinfo?electionId=7000&address=' + address + '&key=<My key>';
   requests.push(request)
   var responses = UrlFetchApp.fetchAll(requests);

  targetSheet.getRange("B2").setValue(responses.length);
  for(var i=0; i<responses.length; i++) {
    var response = JSON.parse(responses[i].getContentText());
    var election = response.election.name;
    targetSheet.getRange("B3").setValue(election);
    var DOlocation = response.dropOffLocations[0].name;
    targetSheet.getRange("B4").setValue(DOlocation);
        
      }

Any help is appreciated

Stephan Cloitre

unread,
Oct 6, 2020, 4:14:19 PM10/6/20
to Google Civic Information API
By the way, this works for the following address: 1822 Resort Drive, Massanutten VA 22840, so it looks like this is a data availability issue?

Arjun Talwar

unread,
Oct 14, 2020, 11:32:42 AM10/14/20
to Google Civic Information API
Hi Stephen
  1. The address you've used "address = '3015 SACRAMENTO AVE ACTON,CA 935100';" has a wrong Pin code and is also not a residential address because of which the API is not returning a response you expect.
  2. The API expects a valid residential address and does not work with other addresses.
  3. Please also note that not all counties are live! in California. You can find the detail if you hover over the cell and look at the comment attached to the Live! cell in the California row (see sheet)
Hope this helps!

Thanks

Stephan Cloitre

unread,
Oct 14, 2020, 11:42:52 AM10/14/20
to Google Civic Information API
Thank you
Reply all
Reply to author
Forward
0 new messages