Add a body to a request by placing @body on its own line. Everything after @body is sent as the request body.
Postchi determines how to encode the body from the Content-Type header when present, or by inspecting the body text when it isn’t.
JSON body
Postchi treats the body as JSON when:
Content-Type: application/json is set, or
- the body starts with
{ or [
Variables inside JSON bodies must be written as quoted string values. Postchi replaces "<username>" with the resolved value and keeps the surrounding quotes so the JSON stays valid.
Form body (URL-encoded)
Postchi treats the body as URL-encoded form data when:
Content-Type: application/x-www-form-urlencoded is set, or
- the body uses
key=value pairs
Each line is a separate form field. Variables work as values here too.
Multipart form body (file uploads)
Use Content-Type: multipart/form-data together with readFile() to attach binary files:
readFile(path) reads the file from disk and attaches it as a binary form part. If you don’t set Content-Type explicitly, Postchi automatically switches to multipart/form-data when it encounters a readFile() call in the body.
readFile() is only valid inside a form body. To inline a text file as the entire body, use readText() instead.
Plain text and other content types
Any Content-Type that isn’t JSON or form-encoded is sent as a plain text body:
Loading the body from a file
For large bodies, keep the content in a separate file and use readText(path) to load it at run time:
Variables in bodies
Variables (<variable_name>) work in all body types:
Values are substituted from the active environment when the request runs. If a variable is missing, Postchi shows an error before sending.