Direct API POST method to another URL

Marcelo Nogueira 20 Reputation points
2024-04-27T13:11:19.82+00:00

Good morning, afternoon or night!! Dear all, I will need to be "listening" to an Access device that will be sending a Json in the POST Method. To do this, I created a (simple) API to do this monitoring and respond with a True or False.

Problem: I need to direct the Post to the Device API url, how can I do this?

[HttpPost]    
public IActionResult EntradaAssociado(

        [FromBody]AcessoAssociadoDto enviarAssociado            

        )

    {

        var associados = _context

           .AssociadoDtos

           .FirstOrDefault(associados => associados.Matricula == enviarAssociado.Matricula);

        if (associados == null) return NotFound();

        var associado = _mapper.Map<AssociadoDto>(associados);

        return CreatedAtAction(nameof(CarregarAssociadoPorMatricula), new { _matricula = associado.Matricula }, associado);

    }


Thank you very much in advanceAt first I created the code by "listening" to the post from my base, which works. Now I need you to listen to the URL that the controller will make available

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,461 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,242 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,391 questions
{count} votes