Skip to content

Request bodies ​

The body is the data a request sends: the JSON of a new record, the fields of a form, a file. Pick a body type on the Body tab and ApiWorkbench shows the right editor and sets the Content-Type header for you.

Choose a body type ​

Open the Body tab and select one of the chips. The tab label then shows the type, for example Body • JSON.

Body typeSendsContent-Type
NoneNothingNone
JSONThe text you typeapplication/json
TextThe text you typetext/plain
XMLThe text you typeapplication/xml
Form URL-encodedName and value pairsapplication/x-www-form-urlencoded
Form dataText fields and file uploadsmultipart/form-data
GraphQLA query and its variables, as JSONapplication/json
Binary fileOne file, byte for byteapplication/octet-stream

Things that apply to every type:

  • Methods. Any method except HEAD sends the body, GET included. HEAD never sends one. Switching the method does not clear the body, so set the type back to None when a request should send nothing.
  • Content-Type. To send a different Content-Type, add your own on the Headers tab. See Headers.
  • Variables. {{variables}} and dynamic variables are filled in when you send, in typed bodies, in form field names and values, and in file paths.

None ​

The request has no body. This is the default and is typical for GET and DELETE. The tab reads This request has no body.

JSON ​

The most common body for APIs. Type the JSON exactly as it should be sent.

json
{
  "name": "Ada Lovelace",
  "email": "ada@example.com",
  "roles": ["admin"]
}

Beautify re-indents the JSON with line breaks and spacing. If the text is not valid JSON, it changes nothing and shows Body is not valid JSON. On a narrow window, Beautify is the wand icon at the end of the chip row.

ApiWorkbench does not check JSON before sending. It sends what you typed, which lets you test how a server handles broken JSON.

Variables work inside JSON. Put quotes around a variable that stands for a string:

json
{
  "id": "{{userId}}",
  "ref": "{{$guid}}",
  "quantity": {{quantity}}
}

More on the format: JSON basics.

Text ​

Plain text, sent as text/plain.

text
Hello server

XML ​

An XML document, sent as application/xml. Use it for SOAP services and older APIs.

xml
<user>
  <name>Ada</name>
  <email>ada@example.com</email>
</user>

For a SOAP service that expects text/xml or a SOAPAction header, add those on the Headers tab.

Form URL-encoded ​

Name and value pairs, the way a plain web form sends them. Use it for classic login forms and for OAuth token endpoints.

  1. Select Form URL-encoded.

  2. Select Add field.

  3. Type the name in Field and the value in Value.

FieldValue
emailada@example.com
remembertrue

The body that goes out is one line, with special characters encoded for you:

text
email=ada%40example.com&remember=true

Untick a row to keep it without sending it.

Form data ​

Text fields plus file uploads in one body, like a web page with a file picker. Each row is either Text or File.

The Body tab set to Form data with a text field named note and a file field named file
A multipart upload: one text field and one file.
  1. Select Form data.

  2. Select Add field and type the field name the server expects.

  3. For a text value, leave the row on Text and type the value.

  4. For an upload, open the Text menu on the row and choose File. Then select the folder icon and pick the file, or type its full path.

  • The multipart Content-Type, with its boundary, is added for you. A Content-Type header you set yourself is replaced for this body type.
  • If a file path does not exist when you send, the request stops with Form file not found: and the path.
  • A File row with an empty path is skipped.
  • Form URL-encoded and Form data share their rows, so you can switch between the two types without retyping. File rows only make sense as Form data.

Files stay on your device

A file row stores the path, not the file. If you export the request and open it on another computer, pick the file again there.

Bulk edit for form fields ​

Bulk edit shows the fields as text, one per line. In Form data, write a file row with @ before the path.

text
note: Paid
// draft: yes
file: @/home/me/invoice.pdf

The full format is under Bulk edit. To send a text value that itself starts with @, write \@.

GraphQL ​

A query in the top box and its variables, as JSON, in the bottom box. Both are sent together as one JSON body. See GraphQL.

Binary file ​

One file sent as the whole body, such as an image, a PDF or a zip.

  1. Select Binary file.

  2. Select Choose file and pick the file, or type its full path in the field.

  3. If the server needs to know the file type, add a Content-Type header, for example image/png. Without one the file is sent as application/octet-stream.

If the path does not exist when you send, the request stops with Body file not found: and the path. The path can contain variables.

Check what was sent ​

The Console shows the request as it went out, with the body and the final headers. Open it from the rail after sending. See Console.

Next steps ​