Skip to content

Commit bd034ce

Browse files
committed
Refactor pc_synonyms() to use GET instead of POST to make CI tests more robust
1 parent 1a344b6 commit bd034ce

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

R/pubchem.R

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -541,23 +541,22 @@ pc_synonyms <- function(query,
541541

542542
if (!missing("choices"))
543543
stop("'choices' is deprecated. Use 'match' instead.")
544-
foo <- function(query, from, verbose, ...) {
545-
if (is.na(query)) {
544+
foo <- function(x, from, verbose, ...) {
545+
if (is.na(x)) {
546546
if (verbose) webchem_message("na")
547547
return(NA)
548548
}
549549
prolog <- "https://pubchem.ncbi.nlm.nih.gov/rest/pug"
550-
input <- paste0("/compound/", from)
550+
input <- paste0("/compound/", from, "/")
551551
output <- "/synonyms/JSON"
552552
if (!is.null(arg))
553553
arg <- paste0("?", arg)
554-
qurl <- paste0(prolog, input, output, arg)
555-
if (verbose) webchem_message("query", query, appendLF = FALSE)
554+
qurl <- paste0(prolog, input, utils::URLencode(x), output, arg)
555+
if (verbose) webchem_message("query", x, appendLF = FALSE)
556556
webchem_sleep(type = 'API')
557-
res <- try(httr::RETRY("POST",
557+
res <- try(httr::RETRY("GET",
558558
qurl,
559559
httr::user_agent(webchem_url()),
560-
body = paste0(from, "=", query),
561560
terminate_on = 404,
562561
quiet = TRUE), silent = TRUE)
563562
if (inherits(res, "try-error")) {

0 commit comments

Comments
 (0)