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

Allow the use of POST #89

Closed
reedacartwright opened this issue Sep 23, 2016 · 9 comments
Closed

Allow the use of POST #89

reedacartwright opened this issue Sep 23, 2016 · 9 comments
Assignees

Comments

@reedacartwright
Copy link

NCBI recommends the use of POST if the number of ids is greater than 200. Right now rentrez always uses GET.

@reedacartwright
Copy link
Author

Here is a work around I hacked together to upload ids.

epost = function(db, id, config=NULL, ...) {
    uri = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/epost.fcgi?"
    args = list(..., email="david.winter@gmail.com",tool='rentrez')
    body = list()
    body$id = paste(id, collapse=",")
    body$db = db
    response <- httr::POST(uri, query=args, config=config, body=body, encode="form")
    if(response$status_code >= 400) {
        stop("Posting ids failed.")
    }
    response = httr::content(response, as="text", encoding="UTF-8")
    record <- xmlTreeParse(response, useInternalNodes=TRUE)
    result <- xpathApply(record, "/ePostResult/*", XML::xmlValue)
    names(result) <- c("QueryKey", "WebEnv")
    class(result) <- c("web_history", "list")
    return(result)
}

@dwinter
Copy link
Member

dwinter commented Oct 25, 2016

Hi @reedacartwright,

Did the advice to use POST come from the NCBI? I was once discouraged from using POST (the http verb) and told to use epost (confusingly via GET). If the policy has changed I can incorporate something like this into the package.

@dwinter
Copy link
Member

dwinter commented Oct 25, 2016

... actually, just as I say that, it seem POST is going to die (see email from NCBI in #86).

@reedacartwright
Copy link
Author

It's in the epost documentation:

UID list. Either a single UID or a comma-delimited list of UIDs may be provided. All of the UIDs must be from the database specified by db. There is no set maximum for the number of UIDs that can be passed to epost, but if more than about 200 UIDs are to be posted, the request should be made using the HTTP POST method.

@dwinter
Copy link
Member

dwinter commented Oct 25, 2016

Hmmm, will email the help desk and see if they can confirm the right way to do this given the apparent end of support for POST mentioned in the other issue.

@cstubben
Copy link

cstubben commented May 17, 2017

Any updates on this issue? I think entrez_post should definitely use httr::POST! It works fine with https and if NCBI does not allow future posts, then I guess they will drop the EPost utility. And rather than support posting with all utilities, maybe just check efetch, esummary and elink and if they use more than 200 ids, then add a message to use entrez_post instead. I often see hacks like this, and they really should post all the ids at once, then use retstart to get the next 10K records if needed.

@dwinter
Copy link
Member

dwinter commented May 25, 2017

Hi @cstubben ,

I have emailed NCBI and will see what they think. If it something they are happy with then I'm very keen to include, but I also don't want to get offside with the people providing the API by doing something that (in some documents...) seems to be against their rules.

@cstubben
Copy link

The docs seem pretty clear to me, "if more than about 200 UIDs are to be provided, the request should be made using the HTTP POST method". I think most rentrez users are violating this and GETting more than 200 ids.

dwinter added a commit that referenced this issue May 31, 2017
NCBI got back and said POST will be supported in the future, so we are
now using POST for requests > 200

Will keep #89 open until there are tests for this.
dwinter added a commit that referenced this issue May 31, 2017
Includes tests for #89, updates to NEWS and DESCRIPTION to note new
release
@dwinter
Copy link
Member

dwinter commented May 31, 2017

Hi @reedacartwright and @cstubben ,

The NCBI is going to be supporting POST, so from now on rentrez will use POST for requests with > 200 IDs. Users should not notice a difference (or have to do anything different). I plan to get in on to CRAN this week, but if you want to check it out/test it before hand you can:

 devtools::install_github("ropensci/rentrez", ref="develop")

@dwinter dwinter self-assigned this Jun 1, 2017
@dwinter dwinter closed this as completed Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants