Making curl calls

Can you please advise how i can make call to below api using R

I wanted to make below call using R
curl -X GET "https://impi.corp.zy.com/internal_data/api/fet/AReco?Date(s)=2020-08-02&Response%20Type=csv&Async=false" -H "accept: application/json" -H "Authorization: 5c81-e875-48f7-98-ee78"

Have you checked the RCurl package, that directly provides access to libcurl?

Probably something like:

response <- RCurl::getURL("https://impi.corp.zy.com/internal_data/api/fet/AReco?Date(s)=2020-08-02&Response%20Type=csv&Async=false",
   httpheader = c(Accept = "application/json",
                  Authorization = "5c81-e875-48f7-98-ee78"),
   verbose = TRUE)

Hi Alexis
Thanks for checking it
I tried this but it gives an error "
Error in function (type, msg, asError = TRUE) :
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

I'm afraid I don't have the answer. It looks to me like a problem in the version of TLS available (perhaps you don't have the latest version of RCurl?).

One thing you can try is the package httr which sometimes works better. Something along these lines:

library(httr)
GET("https://impi.corp.zy.com/internal_data/api/fet/AReco?Date(s)=2020-08-02&Response%20Type=csv&Async=false",
      add_headers(c(Accept = "application/json",
                    Authorization = "5c81-e875-48f7-98-ee78")))

Thanks Alexis, this worked

1 Like

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