If you’re accessing the internet through some sort of company proxy server, then you might have had issues connecting to API’s in R.
I got the problem while trying to use the RSiteCatalyst library (https://randyzwitch.com/rsitecatalyst/), and I didn’t really get any error messages, that made it clear to me what was causing the issue.
But then I stumbled upon the solution, while I was searching Google for a solution, after a lot of unsuccesful attempts.
It helps a lot, if you, more specifically, know what to search for 😉
Apparently, R isn’t automatically using the same proxy setting as Windows.
I don’t know about other OS’, but that’s at least the case for Windows, while using R Studio and a new version of R.
And if you have to access the internet through a proxy, then it won’t work if you’re not going through the proxy as supposed to.
This is where I found the solution:
Yep, also a Randy Zwitch link 🙂
And this is the code you need to add to your R scripts, to make R use the same proxy settings as set in Windows.
library(curl) companyproxy <- curl::ie_proxy_info()$Proxy Sys.setenv(http_proxy=companyproxy) Sys.setenv(https_proxy=companyproxy)
This trick also works, if you’re using R code as a connector in PowerBI!