In python
I use requests
to call an API (cannot share the API itself unfortunately so this is hard to reproduce) in the following way:
import requests
url = url
headers = {'API-key': 'xxxxxxxxxxxxxxxx',
'Content-type': 'application/json',
'Accept': 'application/json'
}
r = requests.get(url, headers = headers, verify=False)
print(r.text)
Here, I think the verify=False
forces request to ignore the SSL certificate (as suggested here). This works fine, however I am not able to reproduce it with httr
the following way:
library(httr)
url <- url
headers <- c('API-key' = 'xxxxxxxxxxxxxxxx',
'Content-type' = 'application/json',
'Accept' = 'application/json'
))
GET(url = url, add_headers(headers = headers)
Now, I believe that verify=False
in the requests
code is the key here, someone suggested that the way to ignore SSL certificates with httr is using set_config()
before a request:
httr::set_config(httr::config(ssl_verifypeer=0L, ssl_verifyhost=0L))
GET(url = url, add_headers(headers = headers))
But it is not working.
$message
[1] "Unauthorized"
$http_status_code
[1] 401
Is httr::set_config(httr::config(ssl_verifypeer=0L, ssl_verifyhost=0L))
the equivalent to verify=False
in a requests
call?