diff --git a/src/ReC.API/Controllers/ActionController.cs b/src/ReC.API/Controllers/ActionController.cs index 8c3d496..471f638 100644 --- a/src/ReC.API/Controllers/ActionController.cs +++ b/src/ReC.API/Controllers/ActionController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using ReC.Application.RecActions.Commands; using System.IO; +using System.Text.Json; namespace ReC.API.Controllers; @@ -29,18 +30,23 @@ public class ActionController(IMediator mediator) : ControllerBase string endpointUri = "https://jsonplaceholder.typicode.com/posts", string? endpointPath = null, string type = "GET", - string bodyQuery = "SELECT NULL AS REQUEST_BODY;") + Dictionary? body = null, + Dictionary? header = null) { if (endpointPath is not null) endpointUri = new Uri(new Uri(endpointUri.TrimEnd('/') + "/"), endpointPath.TrimStart('/')).ToString(); + var bodyJson = JsonSerializer.Serialize(body, options: new() { WriteIndented = false }); + var headerJson = JsonSerializer.Serialize(header, options: new() { WriteIndented = false }); + await mediator.Send(new CreateRecActionCommand() { ProfileId = 2, EndpointUri = endpointUri, Type = type, - BodyQuery = bodyQuery, - Active = true, + BodyQuery = $@"SELECT '{bodyJson}' AS REQUEST_BODY;", + HeaderQuery = $@"SELECT '{headerJson}' AS REQUEST_HEADER;", + Active = true }); return CreatedAtAction(nameof(CreateFakeAction), null);