From 2deb235c8d828af127bd549b0c2c847df168cd86 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 10:07:21 +0100 Subject: [PATCH] Update Post to use CreatedAtAction with Location header Refactored the Post method to return a 201 Created response using CreatedAtAction. This change adds a Location header pointing to the Get action with the relevant actionId, and includes both the new record's ID and actionId in the response body. This improves API usability and aligns with RESTful conventions. --- src/ReC.API/Controllers/OutResController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReC.API/Controllers/OutResController.cs b/src/ReC.API/Controllers/OutResController.cs index ec98e69..3757138 100644 --- a/src/ReC.API/Controllers/OutResController.cs +++ b/src/ReC.API/Controllers/OutResController.cs @@ -72,7 +72,7 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr public async Task Post([FromBody] InsertResultProcedure procedure, CancellationToken cancel) { var id = await mediator.ExecuteInsertProcedure(procedure, cancel: cancel); - return StatusCode(StatusCodes.Status201Created, id); + return CreatedAtAction(nameof(Get), new { actionId = procedure.ActionId }, new { id, procedure.ActionId }); } ///