req_url | R Documentation |
req_url()
replaces the entire URL.
req_url_relative()
navigates to a relative URL.
req_url_query()
modifies individual query components.
req_url_path()
modifies just the path.
req_url_path_append()
adds to the path.
req_url(req, url)
req_url_relative(req, url)
req_url_query(
.req,
...,
.multi = c("error", "comma", "pipe", "explode"),
.space = c("percent", "form")
)
req_url_path(req, ...)
req_url_path_append(req, ...)
req , .req |
A httr2 request object. |
url |
A new URL; either an absolute URL for |
... |
For For |
.multi |
Controls what happens when a value is a vector:
If none of these options work for your needs, you can instead supply a function that takes a character vector of argument values and returns a a single string. |
.space |
How should spaces in query params be escaped? The default,
"percent", uses standard percent encoding (i.e. |
A modified HTTP request.
To modify a URL without creating a request, see url_modify()
and
friends.
To use a template like GET /user/{user}
, see req_template()
.
# Change complete url
req <- request("http://example.com")
req |> req_url("http://google.com")
# Use a relative url
req <- request("http://example.com/a/b/c")
req |> req_url_relative("..")
req |> req_url_relative("/d/e/f")
# 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")
# Modify individual query parameters
req <- request("http://example.com?a=1&b=2")
req |> req_url_query(a = 10)
req |> req_url_query(a = NULL)
req |> req_url_query(c = 3)
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.