dot-GetHTTP: Send an HTTP request.

Description Usage Arguments Details Value Examples

Description

.GetHTTP is an internal function that is not intended to be called by the user. .GetHTTP is called by other FIRST API methods.

Usage

1
.GetHTTP(session, url, mod_since = NULL, only_mod_since = NULL)

Arguments

session

A Session object created with GetSession().

url

A character vector containing a partial FIRST API url. The url argument includes everything to the right of the season. For example, events?teamNumber=team&districtCode=district.

Details

.GETHTTP is a crucial function – it does most of the work for the firstapiR publicly accessible functions. It formulates the HTTP request from the url and session arguments, including final assembly on the url and creating the authorization header. It verifies there are no HTTP errors on the response and checks the response content for properly formatted JSON or XML text. Finally, if a data frame is requested, it converts the response to an R data frame.

.GetHTTP will thow an error if any HTTP code other than 200 is received in the HTTP response. The error message will include the error code and the error message from the response content. See the Response Codes section of the FIRST API documentation for additional details.

.GetHTTP will also throw an error if session$format = "data.frame" and no records are returned.

Value

Returns either JSON text, an XML::XMLNode object, or an R data frame, depending on the value of session$format.

Examples

1
2
sn <- GetSession("username", "key")
.GetHTTP(sn, "events?teamNumber=2557&districtCode=PNW")

irwinsnet/FIRST_api_R documentation built on Dec. 22, 2020, 5:12 p.m.