hrecht / censusapi

R package to retrieve U.S. Census data and metadata via API
https://www.hrecht.com/censusapi/
169 stars 30 forks source link

Bug report: #63

Closed econoint closed 4 years ago

econoint commented 4 years ago

I'm having an issue with pulling data from the pep/population vintage 2018 API. Based on the error code I think it has something to do with URL construction. It seems to be replacing characters such as "," with "%2C" which I'm guessing based on the Census Bureau's API documentation is probably causing the problem. I'm curious where in the code the error is coming from since I didn't have any issues like this when I pulled data form the nonemp API yesterday.

library(tidyverse)
library(censusapi)

capi_key <- read_lines("CENSUSAPIKEY.txt")
popvar <- c("GEO_ID","POP","DENSITY")

getCensus(
  name = "pep/poplulation",
  vintage = 2018,
  key = capi_key,
  vars = popvar,
  region = "county:*",
  regionin = "state:08"
)

Rather than getting the county population and density data for 2018, I got the following error message.

Error in apiParse(req) : The Census Bureau returned the following error message: Error reportHTTP Status 404 - /data/2018/pep/poplulation Your api call was: https://api.census.gov/data/2018/pep/poplulation?key=my_key&get=GEO_ID%2CPOP%2CDENSITY&for=county%3A%2A

Also, I want to say thank you for creating such an awesome package. It has been very useful for me so far. Great work!

hrecht commented 4 years ago

Hi, the issue here is the spelling in the name field - you have an extra l. works for me with pep/population (not popLulation). Glad it's useful!

econoint commented 4 years ago

Wow, clearly staring at my own code to long. Thanks! Sorry for wasting your time on something so silly.

hrecht commented 4 years ago

No worries, we've all been there!