---
description: Reference for the HTTP detection criterion, including status/body matching patterns.
date_published: 2026-08-13
date_modified: 2026-08-13
canonical_url: https://metricshub.org/community-connectors/develop/detection/http.html
---

# Detection by HTTP

On this Page

- [When to Use](#when-to-use)
- [Syntax](#syntax)
- [Properties](#properties)
- [Runtime Behavior](#runtime-behavior)
- [Recommended Pattern](#recommended-pattern)
- [Common Mistakes](#common-mistakes)
- [Examples](#examples)

## When to Use

Use `http` when connector eligibility can be validated through a REST or web endpoint. Typical checks: product signature in body, auth header behavior, or explicit HTTP status validation.

## Syntax

```yaml
connector:
  detection:
    criteria:
    - type: http
      method: GET
      path: /redfish/v1/Systems
      header: "Authorization: Basic %{BASIC_AUTH_BASE64}"
      resultContent: body
      expectedResult: redfish
      errorMessage: Invalid credentials / not a redfish system
```

## Properties

| Property | Required | Default | Description |
| --- | --- | --- | --- |
| `type` | Yes | - | `http`. |
| `method` | No | `GET` | HTTP method (`GET`, `POST`, `PUT`, `DELETE`). |
| `path` | Cond. | none | Path (related to specified protocol/host/port from HTTP config in MetricsHub). |
| `url` | Cond. | none | Absolute/base URL override. |
| `header` | No | none | Request headers string or embedded-file reference. |
| `body` | No | none | Request body string or embedded-file reference. |
| `resultContent` | No | `body` | Which response part to match: `body`, `header`, `all`, `http_status`. |
| `authenticationToken` | No | none | Optional token injected in request content. |
| `expectedResult` | No | none | Regex matched against selected `resultContent`. |
| `errorMessage` | No | none | Connector-authored failure context (for logs/reporting). |
| `forceSerialization` | No | `false` | Guarantees operations are performed sequentially against one host. |

At least one of `path` or `url` must be provided.

## Runtime Behavior

- The specified HTTP request is performed against the targeted host.
- For HTTP status `>= 400`, request processing returns an empty result string.
- If `expectedResult` is absent: criterion succeeds only if selected result is non-empty.
- If `expectedResult` is present: case-insensitive regex match on selected result.

See below example on how the selected HTTP response content is matched with `expectedResult`:

#### Criterion

```yaml
- type: http
  method: GET
  path: /redfish/v1
  resultContent: body
  expectedResult: RedfishVersion
```

#### Result

Selected result (`resultContent: body`):

```json
{
  "@odata.type": "#ServiceRoot.v1_15_0.ServiceRoot",
  "RedfishVersion": "1.17.0"
}
```

✅ The criterion passes because the selected response content matches `expectedResult: RedfishVersion`.

> **Warning**
>
> `expectedResult` only needs to match one line of the selected result content. In HTTP responses, line breaks in JSON, HTML, or similar text are often incidental and may change over time. Avoid regular expressions that rely on exact line boundaries or formatting unless that structure is known to be stable.

## Recommended Pattern

- Prefer two-stage detection for authenticated APIs: 
  
    1. endpoint availability check (`http_status` = `200` or expected redirect/auth code)
    2. authenticated functional check
- For robust product checks, validate status and body separately.
- Keep detection payloads minimal.

## Common Mistakes

- Matching body while endpoint actually returns relevant signal in headers or status.
- Using wide body regexes that accidentally match generic HTML or proxy responses.
- Performing large JSON requests in detection when a tiny health endpoint exists.

## Examples

Community example — the `http` criterion of [Redfish](https://github.com/metricshub/community-connectors/blob/main/src/main/connector/hardware/Redfish/Redfish.yaml), included directly from the connector source (`resultContent` is not set, so it defaults to `body`):

```
- type: http
  method: GET
  header: "Authorization: Basic %{BASIC_AUTH_BASE64}"
  path: /redfish/v1/Systems
  expectedResult: redfish
  errorMessage: Invalid credentials / not a redfish system
```
