8000 Add an example about empty element in body for POST by cderv · Pull Request #563 · r-lib/httr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add an example about empty element in body for POST #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file 8000
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# httr (development version)

* `POST` gains an example on how to use `encode = "raw"` for specific json
string body (@cderv, #563)

* `http_status()` now throws the correct error message if http status code is
not in the list of known codes (@Javdat, #567).

Expand Down
10 changes: 9 additions & 1 deletion R/http-post.r
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@
#' POST(b2, body = list(x = "A simple text string"))
#' POST(b2, body = list(y = upload_file(system.file("CITATION"))))
#' POST(b2, body = list(x = "A simple text string"), encode = "json")
#'
#'
#' # body can also be provided as a json string directly to deal
#' # with specific case, like an empty element in the json string.
#' # passing as string directly
#' POST(b2, body = '{"a":1,"b":{}}', encode = "raw")
#' # or building the json string before
#' json_body <- jsonlite::toJSON(list(a = 1, b = NULL), auto_unbox = TRUE)
#' POST(b2, body = json_body, encode = "raw")
#'
#' # Various types of empty body:
#' POST(b2, body = NULL, verbose())
#' POST(b2, body = FALSE, verbose())
Expand Down
8 changes: 8 additions & 0 deletions man/POST.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0