I'm trying to request data from an API but getting an error. Here's the full code:
library(tidyverse)
library(httr2)
req <- request("https://www.ec.europa.eu/agrifood/api/beef/prices?memberStateCodes=PT&years=2019,2020&months=1,3,9&weeks=5,6,7,8,40,41,42&beginDate=01/09/2019&endDate=02/02/2020&carcassCategories=heifers,cows")
resp <- req |> req_perform()
And the full response error:
Error in req_perform()
:
! Failed to perform HTTP request.
Caused by error in curl::curl_fetch_memory()
:
! OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0
Can anyone suggest a solution? Thanks!
"https://ec.europa.eu/agrifood/api/beef/prices?memberStateCodes=PT&years=2019,2020&months=1,3,9&weeks=5,6,7,8,40,41,42&beginDate=01/09/2019&endDate=02/02/2020&carcassCategories=heifers,cows" %>%
jsonlite::fromJSON()
memberStateCode memberStateName beginDate endDate weekNumber price unit category productCode
1 PT Portugal 27/01/2020 02/02/2020 5 €352.20 €/100Kg Heifers E O4
2 PT Portugal 27/01/2020 02/02/2020 5 €388.70 €/100Kg Young bulls A U2
3 PT Portugal 27/01/2020 02/02/2020 5 €386.60 €/100Kg Young bulls A U3
4 PT Portugal 27/01/2020 02/02/2020 5 €216.20 €/100Kg Cows D O3
5 PT Portugal 27/01/2020 02/02/2020 5 €425.00 €/100Kg Steers C O4
6 PT Portugal 27/01/2020 02/02/2020 5 €369.90 €/100Kg Young bulls A R2