[MS] Data API builder 1.6: Advanced Behaviors with Special HTTP Headers - devamazonaws.blogspot.com

Data API builder (DAB) provides REST and GraphQL endpoints over SQL Server, Azure Cosmos DB, PostgreSQL, MySQL, and SQL Data Warehouse. REST endpoints support several HTTP headers that let you control how requests behave. These headers give you precision over updates, caching, and discovering new resources.

If-Match

By default, DAB treats PUT and PATCH as upserts: update if the row exists, insert if not. Sometimes you need stricter semantics. If-Match provides update-only behavior.

If-Match in DAB only supports *. Any other value is rejected.

Header value Behavior
If-Match: * Update only if the row exists; otherwise 404 Not Found.
Absent Default upsert (insert if missing, update if found).
Anything else Rejected with 400 Bad Request.

Example request that only updates if the row exists:

PUT /api/Books/id/1
If-Match: *
Content-Type: application/json

{
  "title": "The Return of the King"
}

If the record exists, you get 200 OK. If not, you get 404 Not Found. This applies to both PUT and PATCH. DAB does not support ETag comparisons or concurrency tokens.

Read the documentation on If-Match.

Cache-Control

DAB can cache query results in memory or in a distributed cache. The Cache-Control request header lets you override cache behavior. This applies only to DAB’s cache, not browsers or CDNs.

Directive Behavior
no-cache Always query DB and refresh the cache.
no-store Return cache if present; otherwise query DB but don’t store.
only-if-cached Return cached result only, else 504 Gateway Timeout.
Absent Default: return cache if present, else query and cache.
Request example using no-cache.
GET /api/Books
Cache-Control: no-cache
Accept: application/json

Read the documentation on Cache headers.

Location

When you create a resource with POST, DAB includes a Location header showing the path of the new record. For PUT or PATCH that insert rows, it may be omitted.

  • POST inserts: 201 Created with Location.
  • PUT/PATCH updates: 200 OK, no Location.
  • PUT/PATCH inserts: 201 Created, Location may be omitted.

After creating a book with POST, you will see Location: id/123. Clients can then immediately fetch /api/Books/id/123.

Example POST response:

HTTP/1.1 201 Created
Location: id/123
Content-Type: application/json

{
  "id": 123,
  "title": "New Book"
}

Read the documentation on Location.

Summary

Use If-Match for strict updates, Cache-Control to tune caching, and Location to discover new resources. Together, these headers make your APIs predictable and reliable.

[cta-button text="Get Started with Data API builder" url="https://aka.ms/dab/docs" color="btn-primary"]


Post Updated on September 29, 2025 at 06:30PM
Thanks for reading
from devamazonaws.blogspot.com

Comments

Popular posts from this blog

Scenarios capability now generally available for Amazon Q in QuickSight - devamazonaws.blogspot.com

[MS] Introducing Pull Request Annotation for CodeQL and Dependency Scanning in GitHub Advanced Security for Azure DevOps - devamazonaws.blogspot.com

AWS Console Mobile Application adds support for Amazon Lightsail - devamazonaws.blogspot.com