request_make: Make a Google API request

View source: R/request_make.R

request_makeR Documentation

Make a Google API request


Intended primarily for internal use in client packages that provide high-level wrappers for users. request_make() does relatively little:

  • Calls an HTTP method.

  • Adds a user agent.

  • Enforces "json" as the default for encode. This differs from httr's default behaviour, but aligns better with Google APIs.

Typically the input is created with request_build() and the output is processed with response_process().


request_make(x, ..., encode = "json", user_agent = gargle_user_agent())



List. Holds the components for an HTTP request, presumably created with request_develop() or request_build(). Must contain a method and url. If present, body and token are used.


Optional arguments passed through to the HTTP method. Currently neither gargle nor httr checks that all are used, so be aware that unused arguments may be silently ignored.


If the body is a named list, how should it be encoded? Can be one of form (application/x-www-form-urlencoded), multipart, (multipart/form-data), or json (application/json).

For "multipart", list elements can be strings or objects created by upload_file(). For "form", elements are coerced to strings and escaped, use I() to prevent double-escaping. For "json", parameters are automatically "unboxed" (i.e. length 1 vectors are converted to scalars). To preserve a length 1 vector as a vector, wrap in I(). For "raw", either a character or raw vector. You'll need to make sure to set the content_type() yourself.


A user agent string, prepared by httr::user_agent(). When in doubt, a client package should have an internal function that extends gargle_user_agent() by prepending its return value with the client package's name and version.


Object of class response from httr.

See Also

Other requests and responses: request_develop(), response_process()


## Not run: 
req <- gargle::request_build(
  method = "GET",
  path = "path/to/the/resource",
  token = "PRETEND_I_AM_TOKEN"

## End(Not run)

ropenscilabs/gauth documentation built on Sept. 11, 2023, 6:20 a.m.