RETRY {httr} | R Documentation |
Safely retry a request until it succeeds (returns an HTTP status code below 400). It is designed to be kind to the server: after each failure randomly waits up to twice as long. (Technically it uses exponential backoff with jitter, using the approach outlined in https://www.awsarchitectureblog.com/2015/03/backoff.html.)
RETRY(verb, url = NULL, config = list(), ..., body = NULL, encode = c("multipart", "form", "json", "raw"), times = 3, pause_base = 1, pause_cap = 60, handle = NULL, quiet = FALSE)
verb |
Name of verb to use. |
url |
the url of the page to retrieve |
config |
Additional configuration settings such as http
authentication ( |
... |
Further named parameters, such as |
body |
One of the following:
|
encode |
If the body is a named list, how should it be encoded? Can be one of form (application/x-www-form-urlencoded), multipart, (multipart/form-data), or json (application/json). For "multipart", list elements can be strings or objects created by
|
times |
Maximum number of requests to attempt. |
pause_base, pause_cap |
This method uses exponential back-off with
full jitter - this means that each request will randomly wait between 0
and |
handle |
The handle to use with this request. If not
supplied, will be retrieved and reused from the |
quiet |
If |
The last response. Note that if the request doesn't succeed after
times
times this will be a failed request, i.e. you still need
to use stop_for_status()
.
# Succeeds straight away RETRY("GET", "http://httpbin.org/status/200") # Never succeeds RETRY("GET", "http://httpbin.org/status/500")