| req_perform {httr2} | R Documentation |
After preparing a request, call req_perform() to perform it, fetching
the results back to R as a response.
The default HTTP method is GET unless a body (set by req_body_json and
friends) is present, in which case it will be POST. You can override
these defaults with req_method().
req_perform(
req,
path = NULL,
verbosity = NULL,
mock = getOption("httr2_mock", NULL)
)
req |
A request. |
path |
Optionally, path to save body of request. This is useful for large responses since it avoids storing the response in memory. |
verbosity |
How much information to print? This is a wrapper
around
Use |
mock |
A mocking function. If supplied, this function is called
with the request. It should return either |
If request is successful (i.e. the request was successfully
performed and a response with HTTP status code <400 was recieved), an HTTP
response; otherwise throws an error. Override this behaviour with
req_error().
Note that one call to req_perform() may perform multiple HTTP requests:
If the url is redirected with a 301, 302, 303, or 307, curl will
automatically follow the Location header to the new location.
If you have configured retries with req_retry() and the request
fails with a transient problem, req_perform() will try again after
waiting a bit. See req_retry() for details.
If you are using OAuth, and the cached token has expired, req_perform()
will get a new token either using the refresh token (if available)
or by running the OAuth flow.
request("https://google.com") %>%
req_perform()