hen 0.21.0

Run protocol-aware API request collections from the command line or through MCP.
Documentation
---
sidebar_position: 13
title: Binary Request Bodies
description: Send a raw file-backed HTTP body with an explicit content type.
---

Source file:
[examples/binary_request_body.hen](https://gitlab.com/ben_goodman/apps/hen/-/blob/main/examples/binary_request_body.hen)

## What It Demonstrates

- `body_file = @path` for raw file-backed request bodies
- explicit `Content-Type` headers for binary uploads
- assertions against the echoed Buffer-shaped payload returned by Postman Echo

## Key Pattern

```hen
POST https://postman-echo.com/post

body_file = @./files/raw_payload.bin
* Content-Type = application/octet-stream

^ & status == 200
^ & body.headers.content-type == 'application/octet-stream'
^ & body.data.type == 'Buffer'
^ & body.data.data[0] == 114
^ & body.data.data[1] == 97
^ & body.data.data[2] == 119
^ & body.data.data[27] == 49
```

## Run It

```bash
hen verify ./examples/binary_request_body.hen
hen run ./examples/binary_request_body.hen all --non-interactive
```

## What To Notice

- Hen reads the outbound body directly from disk instead of an inline `~~~` block.
- `body_file` paths are resolved relative to the collection file.
- The request body is sent as raw bytes, which matches `curl --data-binary @file` semantics.
- Postman Echo reports an `application/octet-stream` payload as a JSON `Buffer` object, so the
	assertions inspect the returned byte array instead of a plain string body.
- File-backed bodies are only valid for ordinary HTTP requests.

Related reference: [Requests and bodies](../reference/requests-and-bodies.md)