R/tm1_api_request.R

Defines functions tm1_api_request

Documented in tm1_api_request

tm1_api_request <- function(tm1_connection,
                            url, body ="", type = "GET") {

  tm1_auth_key <- tm1_connection$key

  url <- gsub(" ", "%20", url, fixed=TRUE)

  #type <- paste0("httr::", type)

  # request

    tm1_process_return <-
      do.call(get(type, asNamespace("httr")),
              list(url,
                   httr::add_headers("Authorization" = tm1_auth_key),
                   httr::add_headers("Content-Type" = "application/json"),
                   body = body))


  tm1_return <- jsonlite::fromJSON(httr::content(tm1_process_return, "text"))

  return(tm1_return)





}

Try the tm1r package in your browser

Any scripts or data that you put into this service are public.

tm1r documentation built on Dec. 15, 2020, 5:36 p.m.