Skip to contents

Make JAMES POST request

Usage

james_post(
  host = "http://localhost",
  path = character(0),
  query = list(),
  txt = NULL,
  ...
)

Arguments

host

String with the host. The default is "http://localhost".

path

String with the path to the called end point, e.g. "version", "data/upload" or "data/upload/json".

query

A list with query arguments, for example, list(auto_unbox = TRUE) for json output, or list(width = 7.09, height = 7.09) for svglite.

txt

Data set. Could be a URL, local file, JSON string or JSON object.

...

Any other arguments passed to james functions via POST body

Value

Object of class c("james_httr", "response"). The object extends the httr::response object with the components: messages (messages generated by JAMES), warnings (warnings generated by JAMES), parsed (parsed return value of the called end point), session

(the session key).

Examples

if (FALSE) {
url <- paste("http://localhost", "ocpu/library/jamesdemodata",
  "extdata/bds_v1.0/smocc/Laura_S.json", sep = "/")
fn <- system.file("extdata", "bds_v2.0", "smocc", "Laura_S.json",
 package = "jamesdemodata", mustWork = TRUE)
fn <- system.file("extdata", "allegrosultum", "client3.json",
 package = "jamesdemodata", mustWork = TRUE)
js <- read_json_js(txt = fn)
jo <- read_json_jo(txt = fn)

#' try all inputs
m1 <- james_post(path = "data/upload/json", txt = fn)
m2 <- james_post(path = "data/upload/json", txt = js)
m3 <- james_post(path = "data/upload/json", txt = url)
m4 <- james_post(path = "data/upload/json", txt = jo)
}
if (FALSE) {
# create, store and view an A4 SVG plot
r5 <- james_post(path = "/charts/draw/svglite", txt = url,
chartcode = "NMBA", selector = "chartcode",
query = list(height = 29.7/2.54, width = 21/2.54))
tmp <- tempfile(pattern = "chart", fileext = ".svg")
writeLines(r5$parsed, con = tmp)
browseURL(tmp)
unlink(tmp)
}