api_body: Query construction

Description Usage Arguments See Also Examples

View source: R/body.R

Description

Query construction

Usage

1
2
3
api_body(.data, ..., body_value = NULL)

api_body_(.data, ..., .dots, body_value = NULL)

Arguments

.data

Result of a call to api

...

Comma separated list of unquoted variable names. These are combined into a list and passed to whatever http method is used downstream

body_value

one of the following:

  • FALSE: No body

  • NULL: An empty body

  • "": A length 0 body

  • upload_file("path/"): The contents of a file. The mime type will be guessed from the extension, or can be supplied explicitly as the second argument to upload_file()

  • A character or raw vector: sent as is in body. Use content_type to tell the server what sort of data you are sending.

.dots

Used to work around non-standard evaluation

See Also

Other dsl: api_config, api_error_handler, api_path, api_query, api_template, api, auth

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
## NSE
dd <- api("https://httpbin.org/post")
dd %>% api_body(body_value = NULL) %>% http("POST")
dd %>% api_body(body_value = "") %>% http("POST")

## other named parameters are passed as form values
dd %>% api_body(x = hello) %>% http("POST")

# upload a file
file <- "~/some_test.txt"
cat("hello, world", file = file)
dd %>% api_body(x = upload_file("~/some_test.txt")) %>% http("POST")

# A named list
dd %>% api_body(x = hello, y = stuff) %>% http("POST")

## SE
dd %>% api_body_(x = "hello", y = "stuff") %>% http("POST")

## End(Not run)

sckott/request documentation built on Aug. 11, 2018, 6:11 p.m.