httr equivalent to verify in requests (python)

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)

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 issue here, someone suggested that this would help:

httr::set_config(httr::config(ssl_verifypeer=0L, ssl_verifyhost=0L))

GET(url = url, add_headers(headers = headers))

But it is not working. I get unauthorized.

Is httr::set_config(httr::config(ssl_verifypeer=0L, ssl_verifyhost=0L)) the equivalent to verify=False in a requests call?

This has nothing to do with SSL certificates.

You have to write

add_headers(.headers = headers)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.