req_url {httr2} | R Documentation |
Modify request URL
Description
-
req_url()
replaces the entire url -
req_url_query()
modifies the components of the query -
req_url_path()
modifies the path -
req_url_path_append()
adds to the path
Usage
req_url(req, url)
req_url_query(.req, ..., .multi = c("error", "comma", "pipe", "explode"))
req_url_path(req, ...)
req_url_path_append(req, ...)
Arguments
req , .req |
A request. |
url |
New URL; completely replaces existing. |
... |
For For |
.multi |
Controls what happens when an element of
If none of these functions work, you can alternatively supply a function that takes a character vector and returns a string. |
Value
A modified HTTP request.
Examples
req <- request("http://example.com")
# Change url components
req |>
req_url_path_append("a") |>
req_url_path_append("b") |>
req_url_path_append("search.html") |>
req_url_query(q = "the cool ice")
# Change complete url
req |>
req_url("http://google.com")
# Use .multi to control what happens with vector parameters:
req |> req_url_query(id = 100:105, .multi = "comma")
req |> req_url_query(id = 100:105, .multi = "explode")
# If you have query parameters in a list, use !!!
params <- list(a = "1", b = "2")
req |>
req_url_query(!!!params, c = "3")