httr: Error in curl::curl_fetch_memory(url, handle = handle) : Failure when receiving data from the peer

I have seen similar threads, but none were of help.

Anyway, whenever I try to run the following code:

> library(httr)

> test <-GET("https://olinda.bcb.gov.br/olinda/servico/taxaJuros/versao/v1/odata/TaxasJurosDiariaPorInicioPeriodo(InicioPeriodo=@InicioPeriodo)?%40InicioPeriodo=%2706-18-2018%27&%24format=json")

I get the error described in the title:

Error in curl::curl_fetch_memory(url, handle = handle) : 
  Failure when receiving data from the peer

It used to work until last Friday. I have updated R to version 3.5.1, curl to 3.2, RCurl 1.95-4.10 and httr to 1.3.1, the latest available. I have not succeeded with httr::RETRY.

So, what can be done to fix the issue?

Upvotes: 1

Views: 3468

Answers (1)

I've found that using jsonlite::fromJSON() and wrapping the URL in url(), like so

jsonlite::fromJSON(url("https://olinda.bcb.gov.br/olinda/servico/taxaJuros/versao/v1/odata/TaxasJurosDiariaPorInicioPeriodo(InicioPeriodo=@InicioPeriodo)?%40InicioPeriodo=%2706-18-2018%27&%24format=json")

will yield the expected result.

Upvotes: 2

Related Questions