Skip to contents

Upload rows to CatMapper's uploadInputNodes endpoint using authenticated write requests.

Usage

upload_rows(
  df,
  database,
  form_data = list(),
  action = "add_node",
  add_options = list(district = FALSE, recordyear = FALSE),
  properties = NULL,
  merging_type = "0",
  api_key = NULL,
  poll_interval_seconds = 1,
  timeout_seconds = 600,
  url = NULL
)

Arguments

df

Data frame or list of row objects to upload.

database

Target database, typically "SocioMap" or "ArchaMap".

form_data

Named list matching CatMapper edit-page formData.

action

Upload action option. Supported values:

  • "add_node"

  • "add_uses"

  • "update_add"

  • "update_replace"

add_options

Named list with district and recordyear booleans.

properties

Optional vector/list of upload property names to include.

merging_type

Optional merging mode used by merge upload workflows.

api_key

API key used for authenticated write actions. If NULL, CATMAPR_API_KEY is used.

poll_interval_seconds

Polling interval in seconds while waiting for queued upload tasks.

timeout_seconds

Maximum seconds to wait for upload completion.

url

API URL override. If NULL, CATMAPR_API_URL is used when set.

Value

A data frame built from the upload task result rows returned by the API. The function always triggers a background updateWaitingUSES refresh after upload completion; refresh trigger errors are suppressed.

Examples

if (FALSE) { # \dontrun{
result <- upload_rows(
  df = data.frame(
    CMName = "Yoruba",
    Name = "Yoruba",
    CMID = "",
    Key = "Type == Adamana Brown",
    datasetID = "SD1",
    label = "ETHNICITY",
    stringsAsFactors = FALSE
  ),
  database = "SocioMap",
  form_data = list(
    domain = "ETHNICITY",
    subdomain = "ETHNICITY",
    datasetID = "SD1",
    cmNameColumn = "CMName",
    categoryNamesColumn = "Name",
    alternateCategoryNamesColumns = character(0),
    cmidColumn = "CMID",
    keyColumn = "Key"
  ),
  action = "add_uses",
  properties = c("variable"),
  api_key = Sys.getenv("CATMAPR_API_KEY")
)
head(result)
} # }