MCPcopy Create free account
hub / github.com/hashicorp/vault / SetJSONBody

Method SetJSONBody

api/request.go:47–56  ·  view source on GitHub ↗

SetJSONBody is used to set a request body that is a JSON-encoded value.

(val interface{})

Source from the content-addressed store, hash-verified

45
46// SetJSONBody is used to set a request body that is a JSON-encoded value.
47func (r *Request) SetJSONBody(val interface{}) error {
48 buf, err := json.Marshal(val)
49 if err != nil {
50 return err
51 }
52
53 r.Obj = val
54 r.BodyBytes = buf
55 return nil
56}
57
58// ResetJSONBody is used to reset the body for a redirect
59func (r *Request) ResetJSONBody() error {

Calls 1

MarshalMethod · 0.80