December 1st, 2025
0 reactions

Data API builder’s “request-body-strict” Simplifies Client Code

Jerry Nixon
Senior Program Manager

Data API builder (DAB) provides REST and GraphQL endpoints over SQL Server, Azure Cosmos DB, PostgreSQL, MySQL, and SQL Data Warehouse.

Data API builder (DAB) Logo

The request-body-strict configuration value controls how REST endpoints treat unknown JSON properties in the payload:

  • When set to true (default), unknown properties are rejected and an exception is thrown.
  • When set to false, unknown properties are allowed and ignored. This is especially useful for .NET developers.

Read the documentation.

Let’s try it out

The database table

Imagine a simple table called Category with only two columns:

CREATE TABLE Category (
    Id INT PRIMARY KEY,
    Name VARCHAR(100)
)

The configuration file

Create your Data API builder configuration file with the following command line commands:

dab init --database-type mssql --connection-string "<your-connection-string>" --host-mode development
dab add Category --source dbo.Category --permissions anonymous:*
dab start

The JSON payload

When you call the REST endpoint for Category at https://localhost:5001/api/Category, the resulting JSON looks like this:

{
  "value": [
    {
      "Id": 1,
      "Name": "Category 1"
    },
    {
      "Id": 2,
      "Name": "Category 2"
    },
    {
      "Id": 3,
      "Name": "Category 3"
    }
  ]
}

The C# class

To deserialize this JSON in .NET, you would use C# classes similar to these:

public class Root
{
    [JsonPropertyName("value")]
    public List<Category> Categories { get; set; }
}

public class Category
{
    [JsonPropertyName("Id")]
    public int Id { get; set; }
    
    [JsonPropertyName("Name")]
    public string Name { get; set; }
}

Updating data when request-body-strict is true

When request-body-strict is true, you update a record by sending a PATCH request to https://localhost:5001/api/Category/Id/1. The request body cannot include the Id property since it’s already in the URL. This requires creating a separate C# class for updates:

public class Category_NoPK
{
    [JsonPropertyName("Name")] 
    public string Name { get; set; }
}

This allows you to pass the payload to the REST endpoint without errors and successfully update the database record.

Updating data when request-body-strict is false ⭐

When request-body-strict is false, you can send the same PATCH request but include the full Category class in the body. The Id property will simply be ignored. This provides a much better experience for .NET developers, allowing you to reuse the same Category class for both reading and updating.

Yes, it’s that easy.

Conclusion

Using REST to Create, Read, Update, or Delete database records with Data API builder is straightforward. By setting request-body-strict to false, you can write less code with fewer types and simpler payloads when working with your API.

Author

Jerry Nixon
Senior Program Manager

SQL Server Developer Experience Program Manager for Data API builder.

0 comments