Request():setBody()
Send an exact request body instead of encoding parameters.
Signature
setBody(body: string): Request
Parameters
| Parameter | Type | Description |
|---|---|---|
| body | string | Raw payload, for example a JSON document |
Returns
Request, so calls can chain.
Description
Use setBody() for JSON, XML or any API that does not accept form parameters. It replaces
the payload built from setParameter(). Set the matching Content-Type with setHeader().
Example
local response = Request("https://api.example.com/users")
:setHeader("Content-Type", "application/json")
:setBody('{"name":"John","email":"john@example.com"}')
:post()
Compatible Version: 1.0.0.37 and up