0

I am using the R package europepmc (https://cran.r-project.org/web/packages/europepmc/europepmc.pdf) and the function epmc_ftxt for obtaining the full texts of some articles given their PMC ID. However for many articles I keep getting the following error:

"Request failed [404]. Retrying in 1 seconds... Error in epmc_ftxt("PMC2701033") : Not Found (HTTP 404). Failed to retrieve full text.."

That is because the article does not belong to the OpenAccess subset (I guess). However I checked and saw that my University has the license to access that article. So my question is... How can I edit the get request in the function in order to tell epmc_ftxt that I can actually access that article? Code below:

#' Fetch Europe PMC full texts
#'
#' This function loads full texts into R. Full texts are in XML format and are
#' only provided for the Open Access subset of Europe PMC.
#'
#' @param ext_id character, PMCID. 
#'   All full text publications have external IDs starting 'PMC_'
#'
#' @export
#' @return xml_document
#'
#' @examples
#'   \dontrun{
#'   epmc_ftxt("PMC3257301")
#'   epmc_ftxt("PMC3639880")
#'   }
epmc_ftxt <- function(ext_id = NULL) {
  if (!grepl("^PMC", ext_id))
    stop("Please provide a PMCID, i.e. ids starting with 'PMC'")
  # call api
  req <-
    httr::RETRY("GET",
                base_uri(),
                path = paste(rest_path(), ext_id,
                             "fullTextXML", sep = "/"))
  # check for http status
  httr::stop_for_status(req, "retrieve full text.")
  # load xml into r
  httr::content(req, as = "text", encoding = "utf-8") %>%
    xml2::read_xml()
} 
Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Jun 16 '22 at 09:25
  • From the linked documentation: "This function loads full texts into R. Full texts are in XML format and are only provided for the Open Access subset of Europe PMC."; you might try to connect to your University network via VPN e.g. – Jonathan Jun 16 '22 at 10:53

0 Answers0