http: Make a HTTP request

Description Usage Arguments Details Examples

Description

Make a HTTP request

Usage

1
2
3
http(req, method = "GET")

http_client(req)

Arguments

req

A req class object

method

(character) Pick which HTTP method to use. Only GET and POST for now. Default: GET

Details

By default, a GET request is made. Will fix this soon to easily allow a different HTTP verb.

The http function makes the request and gives back the parsed result. Whereas, the http_client function makes the request, but gives back the raw R6 class object, which you can inspect all parts of, modify, etc.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
# high level - http()
api('https://api.github.com/') %>%
  api_path(repos, ropensci, rgbif, commits) %>%
  http()

# low level - http_client()
res <- api('https://api.github.com/') %>%
  api_path(repos, ropensci, rgbif, commits) %>%
  http_client()
res$count()
res$body()
res$status()
res$result
res$links
res$parse()

# Specify HTTP verb
api("http://httpbin.org/post") %>%
   api_body(x = "A simple text string") %>%
   http("POST")

## End(Not run)

request documentation built on May 2, 2019, 7:29 a.m.