# System.Net.Http.Formatting

**Kind:** Service

**Source:** `Pams/API/Pams.API/Pams.API.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`System.Net.Http.Formatting` is a NuGet dependency in the `Pams.API` project for HTTP media-type formatting in legacy ASP.NET Web API. It handles serialization and deserialization of request and response bodies, including JSON payloads, during API processing.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant PamsAPI as Pams.API
    participant Formatting as System.Net.Http.Formatting

    Client->>PamsAPI: Send HTTP request with JSON body
    PamsAPI->>Formatting: Deserialize request content
    Formatting-->>PamsAPI: Return model object
    PamsAPI->>Formatting: Serialize response content
    Formatting-->>Client: Return HTTP response with JSON body
```

## Usage

```ts
type PamsRecord = {
  id: string;
  name: string;
};

async function getPamsRecord(id: string): Promise<PamsRecord> {
  const response = await fetch(`/api/pams/${encodeURIComponent(id)}`, {
    headers: {
      Accept: "application/json",
    },
  });

  if (!response.ok) {
    throw new Error(`Pams.API request failed: ${response.status}`);
  }

  return response.json() as Promise<PamsRecord>;
}
```

## AI Coding Instructions

- Keep `System.Net.Http.Formatting` references aligned with the legacy ASP.NET Web API pipeline in `Pams.API`.
- Ensure API clients send `Content-Type: application/json` for JSON request bodies and request JSON responses with `Accept: application/json`.
- Check formatter configuration before changing serialization behavior, including property naming and null-value handling.
- Avoid removing the package while controllers or configuration still depend on media-type formatter types.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.API` — `Pams/API/Pams.API/Pams.API.csproj`:1
