request.Rd
A function to perform an HTTP request to https://sciencedata.dk or other server.
request(file, URL = "https://sciencedata.dk", method = c("GET", "POST", "PUT", "DELETE"),
anonymous = FALSE, cred = NULL, path = "/files", subdomain = NULL, force = FALSE,
rm.file, ...)
the requested file
protocol and domain of the url
the http verb for the object
unauthenticated user?
vector with username and password as authentication credentials
path to add to the url (optional)
subdomain to add to the url (optional)
force remote file overwriting? (optional and logical)
remove file in local machine? (optional and logical)
further parameters if required
request
is an HTTP request, first aimed to interact with DEiC's (Danish e-Infrastructure Cooperation) RESTful APIs at
https://sciencedata.dk; however, it is possible to specify the URL path and subdomain if necessary.
DEiC's https://sciencedata.dk servers have different types of folders and both personal and shared folders require authentication with credentials.
The path to the shared folders where the files are located must be specified with the path
argument.
However, for personal folders the file
argument that includes the path information. Many times, DEiC's https://sciencedata.dk places the data on a subdomain, and for some methods like PUT
it is required to specify the subdomain as well.
When a file already exists on the remote server, there is a prompt question for overwriting the file when the PUT
method is invoked, and by activating argument force
we can prevent confirmation and replace the file.
Method POST
is not yet supported.
In case that accessing the server requires basic authentication, then package "tcltk
" is required to input the credentials with a widget prompt.
However, there is a cred
argument for performing a basic authentication without a prompt, and public folders
can be accessed without credentials with the option of anonymous
user.
Depends on the method, an action on the server site.
A Response message is returned when the method is PUT
with the URL and items Date
, Status
, Content-Type
.
https://sciencedata.dk/sites/developer/ (retrieved on January 2020)
This function requires "httr
", and aliases for request
are sddk()
and SDDK()
.
httr
, tcltk
## get a public file from remote server as anonymous user
if (FALSE) {
request("filename.extension", method="GET", anonymous=TRUE)}
## put a file in remote server
if (FALSE) {
request("filename.extension", method="PUT")}
## put an existing file in remote server and force overwriting
if (FALSE) {
request("filename.extension", method="PUT", force=TRUE)}
## put an existing file in remote server and remove file from local machine
if (FALSE) {
request("filename.extension", method="PUT", rm.file=TRUE)}
## remove a file in remote server
if (FALSE) {
request("filename.extension", method="DELETE")}