I am testing an internal FHIR api, to pull the data into R. This is a test environment with basic HTTP authentication. It works when I try with python http.client.HTTPSConnection . Also works with API tested online. I am not sure what I am missing when using the httr package in R. I get the following message "Authentication information not present or not in the correct format" .
Appreciate your help. I tried the RonFHIR r package and it does not work either.
require("httr")
require("jsonlite")
username <- "userid"
password <- "****"
token<- authenticate(username, password, type = "basic")
url <-"https://test-web-vt02.univ.edu/Interconnect-fhir/api/FHIR/DSTU2/Patient?family=Joe&Given=Mother&Birthdate=2222-12-22", headers=headers"
headers<- httr::add_headers(
`Content-Type` = "application/json",
`Authorization` = 'Basic dsdsdsdsdsdsd',
'epic-client-id': "alphanumericnumber",
'epic-user-id': "userid",
'epic-user-idtype': "EXTERNAL")
token_request <- GET(url = url, config = list(headers,token))
token_body <- content(token_request, as = 'parsed')
token_body
python code that works
import http.client
conn = http.client.HTTPSConnection("test-web-vt02.univ.edu")
headers = {
'content-type': "application/json",
'authorization': "Basic *****",
'epic-client-id': "alphanumericnumber",
'epic-user-id': "userid",
'epic-user-idtype': "EXTERNAL"
}
conn.request("GET", "/Interconnect-fhir/api/FHIR/DSTU2/Patient?family=Joe&Given=Mother&Birthdate=2222-12-22", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))