fingertipsR
fingertipsR copied to clipboard
RE: 'Error: The API is currently unavailable
Hi there,
I've been trying to get my head around an error that pops up when trying to load in data from the API in RStudio and get the following error message.
'Error: The API is currently unavailable' in the console
I've attached some code as an example
> install.packages("fingertipsR", repos = "https://dev.ropensci.org")
trying URL 'https://dev.ropensci.org/bin/windows/contrib/4.1/fingertipsR_1.0.7.9000.zip'
Content type 'application/zip' length 196829 bytes (192 KB)
downloaded 192 KB
package ‘fingertipsR’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\jared.delbridge\AppData\Local\Temp\RtmpKQ60zg\downloaded_packages
> library(fingertipsR)
Warning message:
package ‘fingertipsR’ was built under R version 4.1.2
> profiles()
Error: The API is currently unavailable
I've included the sessioninfo in case of any conflicting packages that may be interrupting connection.
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] fingertipsR_1.0.7.9000 purrr_0.3.4 Hmisc_4.5-0 ggplot2_3.3.3
[5] Formula_1.2-4 survival_3.2-11 lattice_0.20-44 tidyr_1.1.3
[9] httr_1.4.2 xml2_1.3.2 rvest_1.0.0 plyr_1.8.6
[13] openxlsx_4.2.3 reshape2_1.4.4 lubridate_1.7.10 zoo_1.8-9
[17] readxl_1.3.1 dplyr_1.0.7 pacman_0.5.1
loaded via a namespace (and not attached):
[1] fs_1.5.0 usethis_2.0.1 devtools_2.4.2 RColorBrewer_1.1-2
[5] rprojroot_2.0.2 tools_4.1.0 backports_1.2.1 utf8_1.2.2
[9] R6_2.5.1 DT_0.20 rpart_4.1-15 DBI_1.1.1
[13] colorspace_2.0-1 nnet_7.3-16 withr_2.4.2 tidyselect_1.1.1
[17] gridExtra_2.3 prettyunits_1.1.1 processx_3.5.2 curl_4.3.1
[21] compiler_4.1.0 cli_3.0.1 htmlTable_2.2.1 desc_1.3.0
[25] scales_1.1.1 checkmate_2.0.0 readr_2.0.2 callr_3.7.0
[29] stringr_1.4.0 digest_0.6.28 foreign_0.8-81 base64enc_0.1-3
[33] jpeg_0.1-8.1 pkgconfig_2.0.3 htmltools_0.5.2 sessioninfo_1.1.1
[37] fastmap_1.1.0 htmlwidgets_1.5.4 rlang_0.4.11 rstudioapi_0.13
[41] shiny_1.7.1 generics_0.1.1 jsonlite_1.7.2 zip_2.2.0
[45] magrittr_2.0.1 Matrix_1.3-3 Rcpp_1.0.7 munsell_0.5.0
[49] fansi_0.5.0 shinycssloaders_1.0.0 lifecycle_1.0.1 stringi_1.6.1
[53] yaml_2.2.1 pkgbuild_1.2.0 grid_4.1.0 promises_1.2.0.1
[57] crayon_1.4.2 miniUI_0.1.1.1 splines_4.1.0 hms_1.1.1
[61] knitr_1.33 ps_1.6.0 pillar_1.6.4 pkgload_1.2.1
[65] glue_1.4.2 latticeExtra_0.6-29 data.table_1.14.0 remotes_2.3.0
[69] tzdb_0.2.0 png_0.1-7 vctrs_0.3.8 httpuv_1.6.3
[73] testthat_3.0.2 cellranger_1.1.0 gtable_0.3.0 assertthat_0.2.1
[77] cachem_1.0.5 xfun_0.23 mime_0.12 xtable_1.8-4
[81] later_1.3.0 tibble_3.1.5 memoise_2.0.0 cluster_2.1.2
[85] ellipsis_0.3.2
Not sure exactly what is causing this but if anybody has some insight that would be much appreciated.
Kind regards
Jared Delbridge
Thanks for reporting this. Where are you running this code (ie, office, home etc)? This often is a work firewall issue. Does this link work in your browser using the same computer you are running the code with?
Hi Seb,
I am running from a work computer for Bedford Council, I tried the link you posted and it opens within my Chrome browser.
Not sure if I would have to contact someone at our IT department about the firewall issue, but if I am able to open the link in chrome maybe I don't?
What would you advise?
Many thanks
Jared
Hi Jared,
Are you able to check if that link opens in internet explorer? I don't know if it will make a difference, but it uses a function called curl::ie_get_proxy_for_url()
which uses the proxy settings from internet explorer.
All the best, Seb
So I ran the link in both Edge and IE and both were successful enough to show the text elements in the browser or recognise the JSON file.
i can try running the curl function if you think that might help?
Jared
Hi Jared,
You could try the following and let me know where the error occurs:
test <- "https://fingertips.phe.org.uk/api/profiles"
test <- httr::GET(test,
httr::use_proxy(
curl::ie_get_proxy_for_url(test),
username = "",
password = "",
auth = "ntlm"))
test <- httr::content(test,
"text")
test <- jsonlite::fromJSON(test,
flatten = TRUE)
All the best, Seb
This is what I got as an error.
> test <- "https://fingertips.phe.org.uk/api/profiles"
> test <- httr::GET(test,
+ httr::use_proxy(
+ curl::ie_get_proxy_for_url(test),
+ username = "",
+ password = "",
+ auth = "ntlm"))
Error in curl::curl_fetch_memory(url, handle = handle) :
Received HTTP code 403 from proxy after CONNECT
Many thanks
Jared
That's useful. Could you try this now:
test <- "https://api.coronavirus.data.gov.uk/generic/healthcheck"
test <- httr::GET(test,
httr::use_proxy(
curl::ie_get_proxy_for_url(test),
username = "",
password = "",
auth = "ntlm"))
test <- httr::content(test,
"text")
Seems like we have a similar error. Which is confusing because I've been able to use the coronavirusdata api for other pieces of work without a hitch. So this confuses me a bit more.
> test <- "https://api.coronavirus.data.gov.uk/generic/healthcheck"
> test <- httr::GET(test,
+ httr::use_proxy(
+ curl::ie_get_proxy_for_url(test),
+ username = "",
+ password = "",
+ auth = "ntlm"))
Error in curl::curl_fetch_memory(url, handle = handle) :
Received HTTP code 403 from proxy after CONNECT
Hmmm, that is confusing. That second test was to see whether it was a Fingertips specific issue or not. It seems to be an issue with your IT I think. Perhaps you're working in a new location? Or IT have changed something?
I had a quick read about 403 errors but I'm not an expert, so I wasn't sure what it could be. Perhaps someone in your IT might be able to help though
OK that's fair.
I will start the discussion and see what I can find.
Thanks for the help Seb.
Kind regards
Jared
Hi @gzrcm - do you have the same history as Jared? Have you followed through all of the tests suggested above?
One other thing I can add now is that people looking at this conversation can try the following too, using the latest version of the package:
# Enable repository from ropensci
options(repos = c(
ropensci = 'https://ropensci.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
# Download and install fingertipsR in R
install.packages('fingertipsR')
library(fingertipsR)
profiles(proxy_settings = "none")
Never mind... It wasn't working and yes, I did have the same history as Jared today. But I reinstalled the package and restarted R and it works fine? Bizarre, but it must have been on my end. It was working fine all week, not sure why today is different but resolved. Great package by the way!
Hi, I've currently got this error and profiles(proxy_settings = "none")
doesn't work - although I think it used to. I've tried a couple of different browsers but no luck, this URL doesn't work for me either https://fingertips.phe.org.uk/api/profiles
.
Any suggestions?