---
title: Reqwest
description: Learn how to integrate Allure with reqwest to capture detailed HTTP request and response data in your Rust test reports.
---

# Getting started with Allure Reqwest

[![allure-reqwest crates.io latest version](https://img.shields.io/crates/v/allure-reqwest?style=flat "allure-reqwest crates.io latest version")](https://crates.io/crates/allure-reqwest)

Capture [reqwest](https://docs.rs/reqwest/) HTTP requests and responses as attachments in your [Allure Report](https://allurereport.org/docs/) test reports.

`allure-reqwest` works with any Rust test integration that provides an Allure facade — currently
[Rust Cargo Test](/docs/rust/) — or with `allure-rust-commons` directly.

Info:
The official `allure-rust` repository also publishes [`allure-diesel`](/docs/diesel/) for
recording executed Diesel queries as Allure steps.

## Setting up

1. Make sure you have an Allure integration set up for your test runner. See
   [Rust Cargo Test](/docs/rust/).

1. Choose an integration style and add the dependency.

   **Middleware** — recommended for broad capture with minimal call-site changes. It wraps a
   `reqwest_middleware::ClientWithMiddleware`, so requests keep using a reqwest-style client while
   Allure records them automatically. Requires the `middleware` feature and the
   `reqwest-middleware` crate:

   ```bash
   cargo add allure-reqwest --features middleware
   cargo add reqwest-middleware
   ```

   ```rust
   use allure_reqwest::AllureReqwestMiddleware;
   use reqwest_middleware::ClientBuilder;

   async fn create_order(allure: allure_rust_commons::AllureFacade) -> reqwest::Result<()> {
       let client = ClientBuilder::new(reqwest::Client::new())
           .with(AllureReqwestMiddleware::new(allure))
           .build();

       let response = client
           .post("https://api.example.com/v1/orders")
           .header("content-type", "application/json")
           .body(r#"{"name":"demo"}"#)
           .send()
           .await?;

       response.error_for_status()?;
       Ok(())
   }
   ```

   **Wrapper client** — the smaller alternative when you don't want the `reqwest-middleware`
   dependency, or only need to instrument selected calls. Requests must go through
   `AllureReqwestClient::send`/`execute` instead of a plain `reqwest::Client`:

   ```bash
   cargo add allure-reqwest
   ```

   ```rust
   use allure_reqwest::AllureReqwestClient;

   async fn create_order(allure: allure_rust_commons::AllureFacade) -> reqwest::Result<()> {
       let client = AllureReqwestClient::new(allure);
       let response = client
           .send(
               client
                   .post("https://api.example.com/v1/orders")
                   .header("content-type", "application/json")
                   .body(r#"{"name":"demo"}"#),
           )
           .await?;

       response.error_for_status()?;
       Ok(())
   }
   ```

   Both styles take an `allure_rust_commons::AllureFacade`. Inside a `#[allure_test]` function,
   that's the injected `allure` value; outside one, use
   `allure_rust_commons::current_allure()` or pass the facade through explicitly.

1. Run your tests and generate a report the same way as you would normally — see
   [Rust Cargo Test](/docs/rust/#_3-generate-a-report).

Every request made through an instrumented client is recorded as an
[HTTP exchange attachment](/docs/attachments/#http-exchanges), wrapped in a step (named `HTTP
Exchange` by default). The attachment captures the request method, URL, query parameters, and
headers; the response status, status text, and headers; the exchange start and stop timestamps;
and, when the request fails, the error name and message. Request bodies are captured by default
(up to a size limit); response bodies are opt-in. See the
[attachment schema reference](/docs/reqwest-reference/#attachment-schema) for the exact field
list.

Info:
To prevent secrets from leaking into reports, a default set of headers and query parameters is
redacted before the attachment is written. See
[Allure Reqwest configuration](/docs/reqwest-configuration/) for the full list of defaults and how
to add to them.
