request: Create a new HTTP request

View source: R/req.R

requestR Documentation

Create a new HTTP request

Description

There are three steps needed to perform a HTTP request with httr2:

  1. Create a request object with request(url) (this function).

  2. Define its behaviour with req_ functions, e.g.:

    • req_headers() to set header values.

    • req_url_path() and friends to modify the url.

    • req_body_json() and friends to add a body.

    • req_auth_basic() to perform basic HTTP authentication.

    • req_oauth_auth_code() to use the OAuth auth code flow.

  3. Perform the request and fetch the response with req_perform().

Usage

request(base_url)

Arguments

base_url

Base URL for request.

Value

An HTTP request: an S3 list with class httr2_request.

Examples

request("http://r-project.org")

r-lib/httr2 documentation built on Jan. 11, 2025, 10:21 a.m.