Usage
ru_http_request(
verb,
url,
path = NULL,
query = NULL,
accept = "application/json",
headers = NULL,
un = NULL,
pw = NULL,
body = NULL,
encode = NULL,
dest = NULL,
overwrite = TRUE,
terminate_on = NULL,
retries = get_retries()
)Arguments
- verb
(character) The HTTP verb, e.g.
"GET","POST".- url
(character) The base URL of the ODK Central server, or the complete request URL if
pathisNULL.- path
(character) The request path, e.g.
"v1/projects". IfNULL,urlis used as the complete request URL. Default:NULL.- query
(list) Optional query string parameters. Default:
NULL(no query string).- accept
(character) The
Acceptheader value. Default:"application/json". Set toNULLto send noAcceptheader.- headers
(character) Optional extra headers as a named character vector, e.g.
c("X-Extended-Metadata" = "true"). Default:NULL(no extra headers).- un
(character) The ODK Central username for basic authentication. Default:
NULL(no authentication).- pw
(character) The ODK Central password for basic authentication. Default:
NULL(no authentication).- body
The request body. Default:
NULL(no body).- encode
(character) The body encoding:
"json"sends JSON, anything else sends raw bytes. Default:NULL(no body).- dest
(character) A local file path to stream a download to. Default:
NULL(no streaming, the response is kept in memory).- overwrite
(lgl) Whether to overwrite
destif it exists. Only used withdest. Default:TRUE.- terminate_on
(numeric) HTTP status codes that stop retries immediately. Default:
NULL(only non-transient statuses stop retries).- retries
The number of attempts to retrieve a web resource.
This parameter is given to
RETRY(times = retries).Default: 3.
Details
This is the centralised request helper for ruODK.
It builds an httr2 request from plain data (verb, path, query,
headers, credentials, body) and returns the httr2 response unchanged,
so yell_if_error() and the httr2::resp_body_*() parsers keep working
downstream.
The full URL keeps the legacy query semantics on purpose: query
values that callers pre-encode (for example entitylist_download()'s
$filter) must not be encoded twice.
See also
Other utilities:
attachment_get(),
attachment_link(),
attachment_url(),
drop_null_coords(),
form_schema_parse(),
get_one_attachment(),
get_one_submission(),
get_one_submission_att_list(),
get_one_submission_audit(),
handle_ru_attachments(),
handle_ru_datetimes(),
handle_ru_geopoints(),
handle_ru_geoshapes(),
handle_ru_geotraces(),
isodt_to_local(),
odata_submission_rectangle(),
predict_ruodk_name(),
prepend_uuid(),
split_geopoint(),
split_geoshape(),
split_geotrace(),
strip_uuid(),
tidyeval,
unnest_all()
Examples
if (FALSE) { # \dontrun{
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "me@email.com", pw = "...")
resp <- ruODK:::ru_http_request(
"GET",
url = get_test_url(),
path = "v1/projects",
un = get_test_un(),
pw = get_test_pw()
)
httr2::resp_status(resp)
} # }
