Learn R Programming

httr2 (version 1.0.5)

request: 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)

Value

An HTTP request: an S3 list with class httr2_request.

Arguments

base_url

Base URL for request.

Examples

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

Run the code above in your browser using DataLab