File: verb-POST.Rd

package info (click to toggle)
r-cran-crul 1.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,592 kB
  • sloc: sh: 13; makefile: 2
file content (75 lines) | stat: -rw-r--r-- 1,760 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/verbs.R
\name{verb-POST}
\alias{verb-POST}
\title{HTTP verb info: POST}
\description{
The POST method is used to submit an entity to the specified resource,
often causing a change in state or side effects on the server.
}
\section{The POST method}{

If one or more resources has been created on the origin server as a
result of successfully processing a POST request, the origin server
SHOULD send a 201 (Created) response containing a Location header
field that provides an identifier for the primary resource created
(Section 7.1.2 \url{https://tools.ietf.org/html/rfc7231#section-7.1.2})
and a representation that describes the status of the
request while referring to the new resource(s).

See \url{https://tools.ietf.org/html/rfc7231#section-4.3.3} for further
details.
}

\examples{
\dontrun{
x <- HttpClient$new(url = "https://httpbin.org")

# a named list
x$post(path='post', body = list(hello = "world"))

# a string
x$post(path='post', body = "hello world")

# an empty body request
x$post(path='post')

# encode="form"
res <- x$post(path="post",
  encode = "form",
  body = list(
    custname = 'Jane',
    custtel = '444-4444',
    size = 'small',
    topping = 'bacon',
    comments = 'make it snappy'
  )
)
jsonlite::fromJSON(res$parse("UTF-8"))

# encode="json"
res <- x$post("post",
  encode = "json",
  body = list(
    genus = 'Gagea',
    species = 'pratensis'
  )
)
jsonlite::fromJSON(res$parse())
}

}
\references{
\url{https://tools.ietf.org/html/rfc7231#section-4.3.3}
}
\seealso{
\link{crul-package}

Other verbs: 
\code{\link{verb-DELETE}},
\code{\link{verb-GET}},
\code{\link{verb-HEAD}},
\code{\link{verb-PATCH}},
\code{\link{verb-PUT}}
}
\concept{verbs}