httpRequest | R Documentation |
This function uses curlPerform
to carry out all low-level HTTP
requests (i.e., API calls), converting all input and output to/from JSON as
specified.
httpRequest( url, method = c("GET", "POST", "PUT", "DELETE"), content, httpheader = c(Accept = "application/json", `Content-Type` = "application/json"), curl )
url |
A character string specifying the URL to which an HTTP request will be submitted |
method |
A character string specifying the method to be used to submit the HTTP request |
content |
An optional variable specifying the content to be uploaded during a POST or PUT request |
httpheader |
A character vector specifying the |
curl |
A |
curlPerform
is used in place of getURL
(which does not collect the HTTP header) and getURLContent
(which does not return the HTTP response body in the event of an HTTP error)
If an HTTP error was encountered, a simpleError
object is
returned containing a character vector that consists of an HTTP status
line, followed by the HTTP response body (if it exists).
Otherwise:
If the Content-Type
attribute of the HTTP response body is set to
'application/json'
, the response body is converted from JSON to an
R object, and that object is returned.
If that attribute is set to anything else (or does not exist), the HTTP response body itself is returned.
Adam C. Gower agower@bu.edu
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.