request {sdam}R Documentation

Perform an HTTP request

Description

A function to perform an HTTP request to https://sciencedata.dk or other server.

Usage

request(file, URL = "https://sciencedata.dk", method = c("GET", "POST", "PUT", "DELETE"), 
        anonymous = FALSE, cred = NULL, path = "/files", subdomain = NULL, force = FALSE, 
        rm.file, ...)

Arguments

file

the requested file

URL

protocol and domain of the url

method

the http verb for the object

anonymous

unauthenticated user?

cred

vector with username and password as authentication credentials

path

path to add to the url (optional)

subdomain

subdomain to add to the url (optional)

force

force remote file overwriting? (optional and logical)

rm.file

remove file in local machine? (optional and logical)

...

further parameters if required

Details

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.

Value

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.

Note

This function requires "httr", and aliases for request are sddk() and SDDK().

Author(s)

Antonio Rivero Ostoic

References

https://sciencedata.dk/sites/developer/ (retrieved on January 2020)

https://sciencedata.dk

https://www.deic.dk/

See Also

httr, tcltk

Examples

## get a public file from remote server as anonymous user
## Not run: 
request("filename.extension", method="GET", anonymous=TRUE)
## End(Not run)

## put a file in remote server
## Not run: 
request("filename.extension", method="PUT")
## End(Not run)

## put an existing file in remote server and force overwriting
## Not run: 
request("filename.extension", method="PUT", force=TRUE)
## End(Not run)

## put an existing file in remote server and remove file from local machine
## Not run: 
request("filename.extension", method="PUT", rm.file=TRUE)
## End(Not run)


## remove a file in remote server
## Not run: 
request("filename.extension", method="DELETE")
## End(Not run)


[Package sdam version 1.1.4 Index]