2026-09-11 · Q&A guide

Send JSON Array via Postman Form‑Data for Joi Validation

Step‑by‑step guide on constructing multipart/form‑data in Postman so an array of JSON objects satisfies a Joi schema.

Why Form‑Data and Not Raw JSON?

The API you are calling expects a multipart/form‑data payload, typically because it also handles file uploads. Joi validates the structure after the request is parsed, so the server looks for fields named `files` and `folders` that contain arrays of objects. Sending a raw JSON string would bypass the multipart parser and fail the validation.

Naming Convention for Nested Objects

When you use Postman's **form‑data** tab, each key becomes a separate part. To represent an array of objects you must flatten the hierarchy using bracket notation. For example, the first file object is expressed as `files[0][fileId]`. The second becomes `files[1][fileId]`. The same pattern applies to the `folders` array.

files[0][fileId]   →  f28019d7-9268-4013-bacb-67ed96eb095f
files[1][fileId]   →  51e99e3d-755a-4530-9eed-f08d20cbfe8b
folders[0][folderId] →  a1b2c3d4‑e5f6‑7890‑abcd‑ef1234567890

Configuring Postman

1. Open the **Body** tab and select **form‑data**. 2. Add a new row for each element using the bracket syntax described above. 3. Set the **type** of each row to **Text** (unless you are also uploading a file, then choose **File**). 4. Leave the **Content‑Type** header blank; Postman will generate the correct `multipart/form-data; boundary=…` header automatically. 5. Click **Send** and verify that the server receives a structure matching the Joi schema.

Quick Postman Screenshot Example

Below is a minimal representation of what the form‑data table should look like:

Key                     | Value
------------------------|------------------------------------------
files[0][fileId]        | f28019d7-9268-4013-bacb-67ed96eb095f
files[1][fileId]        | 51e99e3d-755a-4530-9eed-f08d20cbfe8b
folders[0][folderId]   | a1b2c3d4-e5f6-7890-abcd-ef1234567890

Testing the Payload with a Mock Server

If you want to double‑check the payload before hitting the real endpoint, spin up a quick Node.js server that uses the same Joi schema. Log `req.body` after `multer` or `express‑formidable` parses the multipart request. You should see an object like `{ files: [{ fileId: '…' }, { fileId: '…' }], folders: [{ folderId: '…' }] }`. Matching this shape confirms that Postman is sending the data correctly.

Takeaway: Use bracket notation (e.g., `files[0][fileId]`) in Postman's form‑data to send arrays of JSON objects that satisfy Joi validation.

People also ask

Can I send the whole array as a single JSON string?

Yes, but only if the server parses the string back into an object. With strict multipart parsing the bracket notation is required.

What if I also need to upload a real file alongside the IDs?

Add a row with key `files[0][file]` (type **File**) and keep `files[0][fileId]` as a text field; the server can read both the binary and the ID.

Inspired by a public discussion on Stack Overflow. This article is an original explanation for learners.

← All posts