【问题标题】:httr: Error in curl::curl_fetch_memory(url, handle = handle) : Failure when receiving data from the peerhttr: curl::curl_fetch_memory(url, handle = handle) 中的错误:从对等方接收数据时失败
【发布时间】:2018-12-18 10:05:51
【问题描述】:

我看过类似的帖子,但没有任何帮助。

无论如何,每当我尝试运行以下代码时:

> 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")

我得到了标题中描述的错误:

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

它曾经工作到上周五。我已将 R 更新到 3.5.1 版,将 curl 更新到 3.2,将 RCurl 1.95-4.10 和 httr 更新到 1.3.1,这是最新可用的。我没有成功使用 httr::RETRY。

那么,有什么办法可以解决这个问题呢?

【问题讨论】:

    标签: r api curl httr


    【解决方案1】:

    我发现使用 jsonlite::fromJSON() 并将 URL 包装在 url() 中,就像这样

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

    将产生预期的结果。

    【讨论】:

      猜你喜欢
      • 2016-11-11
      • 2020-03-03
      • 1970-01-01
      • 2018-12-26
      • 2020-03-31
      • 2017-12-14
      • 2021-11-26
      • 2015-10-22
      • 2020-09-20
      相关资源
      最近更新 更多