> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# DotHttp Analyzer Diagnostics

> Reference documentation for all diagnostic messages produced by the Breakdance.DotHttp source generator.

The DotHttp source generator analyzes `.http` files at compile time and reports diagnostics for issues it encounters.
This page documents all diagnostic rules and provides guidance on resolving them.

## Overview

| Rule ID | Title | Severity | Category |
| - | - | - | - |
| [DOTHTTP001](#dothttp001) | HTTP request line error | Error | DotHttp |
| [DOTHTTP002](#dothttp002) | HTTP header error | Error | DotHttp |
| [DOTHTTP003](#dothttp003) | HTTP variable error | Error | DotHttp |
| [DOTHTTP004](#dothttp004) | HTTP body warning | Warning | DotHttp |
| [DOTHTTP005](#dothttp005) | Unknown HTTP method | Warning | DotHttp |

***

## DOTHTTP001

**HTTP request line error**

> [card] Details
>
> | Property | Value |
> | - | - |
> | **Rule ID** | DOTHTTP001 |
> | **Severity** | Error |
> | **Category** | DotHttp |
> | **Enabled** | Yes |

### Description

This error occurs when the parser cannot interpret the HTTP request line. The request line must follow the format:
`METHOD URL [HTTP/version]`

### Cause

Common causes include:

* Missing HTTP method (GET, POST, PUT, DELETE, etc.)
* Missing URL
* Invalid URL format
* Malformed HTTP version specifier

### How to Fix

Ensure your request line follows the correct format:

```http Correct theme={"dark"}
GET https://api.example.com/users HTTP/1.1
```

```http Correct (without version) theme={"dark"}
POST https://api.example.com/users
```

```http Incorrect theme={"dark"}
https://api.example.com/users
```

***

## DOTHTTP002

**HTTP header error**

> [card] Details
>
> | Property | Value |
> | - | - |
> | **Rule ID** | DOTHTTP002 |
> | **Severity** | Error |
> | **Category** | DotHttp |
> | **Enabled** | Yes |

### Description

This error occurs when an HTTP header line cannot be parsed correctly.

### Cause

Common causes include:

* Missing colon separator between header name and value
* Invalid header name characters
* Header placed after request body

### How to Fix

Headers must use the format `Header-Name: value` and appear before the request body:

```http Correct theme={"dark"}
GET https://api.example.com/users
Content-Type: application/json
Authorization: Bearer token123

{"key": "value"}
```

```http Incorrect - Missing colon theme={"dark"}
GET https://api.example.com/users
Content-Type application/json
```

```http Incorrect - Header after body theme={"dark"}
GET https://api.example.com/users

{"key": "value"}
Content-Type: application/json
```

***

## DOTHTTP003

**HTTP variable error**

> [card] Details
>
> | Property | Value |
> | - | - |
> | **Rule ID** | DOTHTTP003 |
> | **Severity** | Error |
> | **Category** | DotHttp |
> | **Enabled** | Yes |

### Description

This error occurs when a variable definition or reference is malformed.

### Cause

Common causes include:

* Unclosed variable reference (`{{variable` without closing `}}`)
* Invalid variable name syntax
* Malformed variable definition line

### How to Fix

Variable definitions use `@name = value` syntax, and references use `{{name}}`:

```http Correct theme={"dark"}
@baseUrl = https://api.example.com
@apiKey = my-secret-key

GET {{baseUrl}}/users
Authorization: Bearer {{apiKey}}
```

```http Incorrect - Unclosed variable theme={"dark"}
GET {{baseUrl/users
```

```http Incorrect - Invalid definition theme={"dark"}
baseUrl = https://api.example.com
```

***

## DOTHTTP004

**HTTP body warning**

> [card] Details
>
> | Property | Value |
> | - | - |
> | **Rule ID** | DOTHTTP004 |
> | **Severity** | Warning |
> | **Category** | DotHttp |
> | **Enabled** | Yes |

### Description

This warning indicates a potential issue with the request body that may cause unexpected behavior but does not prevent parsing.

### Cause

Common causes include:

* Request body on a GET request (unusual but technically allowed)
* Body without corresponding Content-Type header
* Possible JSON syntax issues

### How to Fix

Consider adding appropriate headers and reviewing the body content:

```http Recommended theme={"dark"}
POST https://api.example.com/users
Content-Type: application/json

{
    "name": "John Doe",
    "email": "john@example.com"
}
```

```http Warning - Body without Content-Type theme={"dark"}
POST https://api.example.com/users

{"name": "John Doe"}
```

***

## DOTHTTP005

**Unknown HTTP method**

> [card] Details
>
> | Property | Value |
> | - | - |
> | **Rule ID** | DOTHTTP005 |
> | **Severity** | Warning |
> | **Category** | DotHttp |
> | **Enabled** | Yes |

### Description

This warning is reported when the HTTP method is not one of the standard methods. The request will still be processed, but using non-standard methods may cause issues with some servers.

### Standard Methods

The following HTTP methods are recognized without warning:

* `GET`, `POST`, `PUT`, `DELETE`, `PATCH`
* `HEAD`, `OPTIONS`, `TRACE`, `CONNECT`

### Custom Methods

If you need to use a custom HTTP method (some APIs use them), you can safely ignore this warning. The request will be generated with the custom method.

```http Standard - No warning theme={"dark"}
GET https://api.example.com/users
```

```http Custom - Warning reported theme={"dark"}
PURGE https://cdn.example.com/cache/items
```

***

## Suppressing Diagnostics

If you need to suppress a diagnostic, you can use standard suppression techniques:

### In Code

```csharp theme={"dark"}
#pragma warning disable DOTHTTP004
// Code that triggers the warning
#pragma warning restore DOTHTTP004
```

### In Project File

```xml theme={"dark"}
<PropertyGroup>
    <NoWarn>$(NoWarn);DOTHTTP004</NoWarn>
</PropertyGroup>
```

### In EditorConfig

```ini theme={"dark"}
[*.http]
dotnet_diagnostic.DOTHTTP004.severity = none
```

> [!NOTE]
>
> Suppressing errors (DOTHTTP001-003) is not recommended as they indicate parsing failures that will prevent test generation.

## Related Resources

> [card] [.http File Testing](https://easyaf.nimbleapps.cloud/breakdance/guides/web/dothttp-testing)
>
> Learn how to write tests using the .http file format

> [card] [DotHttp API Reference](https://easyaf.nimbleapps.cloud/breakdance/api-reference/CloudNimble/Breakdance/DotHttp/index.md)
>
> Full API documentation for the DotHttp library


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.