post_config: Function for posting chart configurations.

Description Usage Arguments Source Examples

View source: R/post_config.R

Description

post_config submits JSON configuration lists.

Usage

1
2
3
4
post_config(config = stop("'config' must be specified"), ...,
  url = "https://stats.oecd.org/share",
  data_viewer = "https://stats.oecd.org", show = FALSE, post = TRUE,
  path = NA, response = FALSE, auto_unbox = TRUE, null = "null")

Arguments

config

a configuration list according to the API definition

...

additional parameters supplied to httr:POST, e.g. httr::verbose()

url

the POST API endpoint offering /share and /chart services, e.g. http://vs-webdev-1:89 or http://stats.oecd.org

show

boolean print the created JSON object

path

write the JSON object to a file on disk

auto_unbox

automatically ‘unbox’ all atomic vectors of length 1 (see jsonlite::toJSON)

null

how to encode NULL values within a list: must be one of 'null' or 'list' (see jsonlite::toJSON)

Source

httr was created by Hadley Wickham, see https://cran.r-project.org/web/packages/httr/index.html; jsonlite was created by Jeroen Ooms et al., see https://cran.r-project.org/web/packages/jsonlite/index.html.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
query <- "KEI/PRINTO01+PRMNTO01.AUS+AUT+BEL+CAN+CHL+CZE+DNK+EST+FIN+FRA.GP.A/all?startTime=2015&endTime=2015"
chartconfig <- create_config(sdmx_data_query = query, type = "BarChart", logo = FALSE)
post_config(config = chartconfig, url = "http://stats.oecd.org", response = TRUE)

## write to disk for debugging
outfile <- tempfile(pattern = "chartconfig_", fileext = ".json")
post_config(config = chartconfig, path = outfile)
filecon <- file(outfile)
readLines(con = filecon)
close(filecon)

R4IO/rcw documentation built on Feb. 3, 2020, 11:46 a.m.