Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

countyweather: Error: lexical error: invalid char in json text. <!DOCTYPE HTML PUBLIC "-//IETF/ #338

Closed
MalenkiiMalchik opened this issue Nov 29, 2019 · 3 comments
Milestone

Comments

@MalenkiiMalchik
Copy link

MalenkiiMalchik commented Nov 29, 2019

Hi all - I'm encountering trouble using the countyweather package that pulls and aggregates data from the noaa api. I'm using more or less exactly the example that its creator provides here: https://cran.r-project.org/web/packages/countyweather/vignettes/countyweather.html, but no luck on anything. Any ideas?

The code I'm using:

henry_precip <- daily_fips(fips = "01067", date_min = "2010-01-01", 
                            date_max = "2010-02-01", var = "temperature")

The error is as follows:

Error: lexical error: invalid char in json text.
<!DOCTYPE HTML PUBLIC "-//IETF/
(right here) ------^

Session Info
sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] jsonlite_1.6        usethis_1.5.1       tictoc_1.0          skimr_1.0.7         lubridate_1.7.4     forcats_0.4.0      
 [7] stringr_1.4.0       dplyr_0.8.3         purrr_0.3.2         readr_1.3.1         tidyr_0.8.3         tibble_2.1.3       
[13] ggplot2_3.2.1       tidyverse_1.2.1     rnoaa_0.9.4         countyweather_0.1.0

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.5 xfun_0.9         haven_2.1.1      lattice_0.20-38  colorspace_1.4-1 generics_0.0.2   vctrs_0.2.0     
 [8] XML_3.98-1.20    rlang_0.4.0      pillar_1.4.2     withr_2.1.2      httpcode_0.2.0   glue_1.3.1       rappdirs_0.3.1  
[15] readxl_1.3.1     modelr_0.1.5     cellranger_1.1.0 munsell_0.5.0    gtable_0.3.0     rvest_0.3.4      knitr_1.24      
[22] curl_4.0         hoardr_0.5.2     urltools_1.7.3   triebeard_0.3.0  broom_0.5.2      Rcpp_1.0.2       scales_1.0.0    
[29] backports_1.1.4  fs_1.3.1         gridExtra_2.3    isdparser_0.3.0  hms_0.5.1        digest_0.6.20    stringi_1.4.3   
[36] grid_3.6.1       cli_1.1.0        tools_3.6.1      magrittr_1.5     lazyeval_0.2.2   crul_0.9.0       crayon_1.3.4    
[43] pkgconfig_2.0.2  zeallot_0.1.0    xml2_1.2.2       assertthat_0.2.1 httr_1.4.1       rstudioapi_0.10  R6_2.4.0        
[50] nlme_3.1-140     compiler_3.6.1
@sckott
Copy link
Contributor

sckott commented Nov 30, 2019

thanks for the issue @MalenkiiMalchik

At least part of NOAA is down right now - so it's an atypical time. Having said that, we could definitely fail better, so i'm fixing now.

@sckott sckott added this to the v0.9.6 milestone Nov 30, 2019
sckott added a commit that referenced this issue Dec 1, 2019
internal fxns were trying to parse json if the status code was bad
but noaa returns html when bad http code - trycatch json parse now
add webmockr tests to mock this behavior
bump pkg version
makefile change
@sckott
Copy link
Contributor

sckott commented Dec 1, 2019

this will fail better now, if you reinstall, should look like:

daily_fips(fips = "01067", date_min = "2010-01-01", date_max = "2010-02-01", 
  var = "temperature")
#> Error: Service Unavailable (HTTP 503)

i assume the service will be back tomorrow, but i can't say for sure

@sckott sckott closed this as completed Dec 1, 2019
@MalenkiiMalchik
Copy link
Author

MalenkiiMalchik commented Dec 1, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants