Skip to contents

Sends a JSON object to a P2 API endpoint url using an api_key and returns T/F based on success_codes

Usage

p2_execute_api(
  url,
  object = list(),
  success_codes = c(200, 201, 202),
  method = "POST",
  api_key = keyring::key_get("P2_API"),
  dry_run = FALSE
)

Arguments

url

character, endpoint url for the API

object

list to be converted into JSON using jsonlite::toJSON

success_codes,

integer vector of success codes returned by the API

method,

character name of the httr function to call, usually POST or PUT

api_key

Active Campaign API key, defaults to keyring::key_get("P2_API")

dry_run

boolean, nothing will be changed in P2 if set to TRUE

Value

TRUE if success, FALSE if not