Skip to content

[Bug]: REST PATCH does not work with Identity keys #2663

@JerryNixon

Description

@JerryNixon

What?

Endpoints that support Upsert currently require the key in the route. But when the entity uses identity or auto-generated keys, this route becomes impossible to fulfill.

PATCH

PATCH /api/Entity/Id/{Id}

The URL requires a key, which new records with auto-generated keys don't have.

PUT

PUT /api/Entity/Id/{Id}

The URL requires a key, which new records with auto-generated keys don't have.

Fix

Introduce alternative routes that do not require a key in the URL:

  • PATCH /entity — handles partial updates and upserts without needing an Id in the path
  • PUT /entity — handles full replacements or upserts for records with auto-generated keys

ASP.NET supports multiple routes per controller, so this dual-route setup is valid. For backward compatibility, we keep the original routes, but add these new keyless ones to support common identity scenarios. The internal engine logic should be reusable—only the API surface changes.

Other

To keep Swagger/OpenAPI output clean, we might omit the legacy routes from documentation. Otherwise, two PATCH or PUT operations per entity will appear, even though only one is typically the intended usage pattern.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions