C# Which one to use when request has object input? HTTPGET request using '[FromQuery]' attribute or HTTPPOST request

44 Views Asked by At

We have a request like '[HttpGet("GetAllDtoWithSearch")]'. Despite being a GET request, it takes a DTO(object) using the [FromQuery] attribute. However, the URL for the request, 'https://localhost:123456/api/ControllerName/GetAllDtoWithSearch?customerName=blabla&comment=thisIsaComment', becomes longer as it includes all the parameters present in the DTO(object).

For GET requests that involve multiple parameters and are designed for retrieval, is it appropriate to use [FromQuery], or should we make the HTTP request a POST and send it that way?

The URL for the POST request is: https://localhost:123456/api/ControllerName/GetAllDtoWithSearch

We use both of these two at different requests. But which one is appropriate in general apis.

0

There are 0 best solutions below