Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: entrez_post does not use POST method for >200 IDs #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

allenbaron
Copy link

When args$id is present as input to make_entrez_query() (e.g. from entrez_post) the IDs are collapsed to a string (length = 1) before args$id length > 200 is used to determine whether to use the POST method. It always uses the GET method because it's always length <= 1.

This is a minor change that fixes this issue. It passes your testthat::test() with 4 warnings. May need to be combined with PR #164 if implementing fix for Issue #163.

Reprex - Original code

library(rentrez)

pmid <- 25348409

# Get PubMed articles PMIDs that cite pmid (234)
citedin_pmids <- rentrez::entrez_link(
    dbfrom = "pubmed",
    id = pmid,
    db = "pubmed",
    linkname = "pubmed_pubmed_citedin"
)$links$pubmed_pubmed_citedin


# Try to create web history with epost ------------------------------------

# even GET method works above 200 (using 234 IDs)
rentrez::entrez_post(
    db = "pubmed",
    id = citedin_pmids,
    web_history = NULL
)
#> Web history object (QueryKey = 1, WebEnv = MCID_6127c75...)

# but not around ~500 (using 468 IDs)
ids_rep2 <- rep(citedin_pmids, 2)
rentrez::entrez_post(
    db = "pubmed",
    id = ids_rep2,
    web_history = NULL
)
#> Error in entrez_check(response): HTTP failure 414, the request is too large. For large requests, try using web history as described in the rentrez tutorial

Created on 2021-08-26 by the reprex package (v2.0.1)

Reprex - After fix

library(rentrez)

pmid <- 25348409

# Get PubMed articles PMIDs that cite pmid (234)
citedin_pmids <- rentrez::entrez_link(
    dbfrom = "pubmed",
    id = pmid,
    db = "pubmed",
    linkname = "pubmed_pubmed_citedin"
)$links$pubmed_pubmed_citedin


# Try to create web history with epost ------------------------------------

# even GET method works above 200 (using 234 IDs)
rentrez::entrez_post(
    db = "pubmed",
    id = citedin_pmids,
    web_history = NULL
)
#> Web history object (QueryKey = 1, WebEnv = MCID_6127cb8...)

# but not around ~500 (using 468 IDs) --> NOW WORKS
ids_rep2 <- rep(citedin_pmids, 2)
rentrez::entrez_post(
    db = "pubmed",
    id = ids_rep2,
    web_history = NULL
)
#> Web history object (QueryKey = 1, WebEnv = MCID_6127cb8...)

Created on 2021-08-26 by the reprex package (v2.0.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant