Skip to contents

A PATCH request is used to alter an existing record in the database. If the desire is to store new data to the database a POST request should be used.

Usage

api_patch(
  api_name,
  endpoint,
  id,
  body = NULL,
  dry_run = FALSE,
  verbosity = 0,
  timeout = 300
)

api_patch_multi(
  api_name,
  endpoint,
  id,
  body = NULL,
  dry_run = FALSE,
  verbosity = 0,
  timeout = 300
)

Arguments

api_name

the name of the API to call

endpoint

the API endpoint to make the request to

id

the id of the record to be edited

body

a list or tibble that will be passed as the body of the request to the API

dry_run

if TRUE, the call is printed to the console instead of being sent to the API, which is useful for debugging

verbosity

How much information to print to the console. Defaults to 0.

  • 0: no output

  • 1: show headers

  • 2: show headers and body

  • 3: show headers, body, and curl status messages

timeout

request timeout in seconds (default is 300)

Value

a response object

Details

Similar to POST a single and multiple entry version of this function is available.

See also

api_get() to retrieve data, api_post() to create records, api_delete() to remove records

Examples

if (FALSE) { # \dontrun{
updates <- tibble::tibble(age_class = "Sub-Adult")
api_patch("counts", "projects/age-classes", id = 42, body = updates)

# Batch update
api_patch_multi("counts", "projects/age-classes/multiple",
  id = c(42, 43),
  body = tibble::tibble(age_class = c("Sub-Adult", "Juvenile"))
)
} # }