RETRY/GET API error in httr package R

Here is my code:

library(httr)
repeat {
request<-list(status_code=0)
  while(request$status_code!=200){
    try({
      request <- RETRY("GET",
    "https://api.coinex.com/v1/market/deals?market=BTCUSDT&limit=1",
    times = 10,
    pause_base = 0.1, pause_cap = 60, pause_min = 0.1)
    })
  }
response <- content(request, as = "text", encoding = "UTF-8")
#some functions
print('some results')
}

It works fine most of the time but at some seconds it produced tens of the following error:

Error in UseMethod("http_error") : 
  no applicable method for 'http_error' applied to an object of class "c('simpleError', 'error', 'condition')"

what does this error even mean? how can I avoid it or see it less frequently? sometimes it covers all my console and I can't find the results among them. of course, I can save the results in an object but the main issue is about the error, besides I prefer them in the console to know about them at time.
I used to think this error relates to when API fails but I saw the following warning a very few times which relates to that:

Request failed [502]. Retrying in 0.1 seconds...

This is an error in an older version of httr (you find some information on it in the GitHub Pull Request). It was fixed in httr 1.4.1, so simply update the package and things should work properly.

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.