---
title: Serialize request body
summary: Serialize an outbound request body to JSON honoring configured serializer settings.
status: draft
owner: bendy
last_reviewed: 2026-09-15
library: SAIF.Web.API.Clients.35
reference_type: package
operation_id: OP-04
trigger: RestSharp invokes AddJsonBody, which calls JsonSerializer.Serialize
---

# Serialize request body

This operation converts a request body object into an indented JSON string using a Newtonsoft-based serializer configured with the client's `DateTimeZoneHandling` and member-handling settings.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-04 |
| **Trigger** | RestSharp calls `ISerializer.Serialize(object)` when `JsonHttpClient.GetJsonResponse` invokes `request.AddJsonBody(body)`. |
| **Inputs** | Request body object. |
| **Outputs** | Indented JSON string, with `"` as the quote character. |
| **Primary components** | `JsonSerializer.Serialize`, `JsonSerializer` constructor |
| **Entry point** | src/SAIF.Web.API.Clients/JsonSerializer.cs |

## Steps

1. Open a `StringWriter`/`JsonTextWriter` pair for the output.
2. Set `Formatting.Indented` and `QuoteChar = '"'` on the writer.
3. Call `_serializer.Serialize(...)`, applying `MissingMemberHandling.Ignore`, `NullValueHandling.Include`, `DefaultValueHandling.Include`, and the configured `DateTimeZoneHandling` ([BR-07](../business-rules.md#br-07-configured-datetimezonehandling-applied-to-serialization), [BR-21](../business-rules.md#br-21-serialization-member-and-value-handling)).
4. Return the resulting JSON string to RestSharp for inclusion in the request body.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start(["AddJsonBody invoked by<br>RestSharp"]) --> S1["Open StringWriter and<br>JsonTextWriter"]
	S1 --> S2["Configure<br>Formatting.Indented and<br>QuoteChar"]
	S2 --> S3["Serialize object with<br>configured settings"]
	S3 --> EndOk([Return JSON string])
```

## Failure and edge-case behavior
- No error handling is performed within this operation; serialization exceptions from Newtonsoft propagate to the caller unmodified.*

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- src/SAIF.Web.API.Clients/JsonSerializer.cs
