Issue
[HttpGet]
public async Task<IActionResult> GetAllTransaction()
{
var transaction = await _fullStackDbContext.Transactions.ToListAsync();
return Ok(transaction);
}
[HttpGet]
public async Task<IActionResult> GetTotalItem()
{
var transaction= await _fullStackDbContext.Transactions.FromSqlRaw("Select Name from Transactions").ToListAsync();
return Ok(transaction);
}
I can list and try out the first HttpGet in swagger but in the second HttpGet, swagger returns a 500 error response in the browser console. Is my query syntax wrong or another problem? Also, I'm not sure if this is the method to do custom SQL queries in ASP.NET Core Web API for SQL Server
Solution
Alright, thank you guys I have known the answer. Apparently, the error message gives this swagger JSON link that pointed to the error. I thought every error appear in the browser console but this one must be clicked.
The error is SwaggerGeneratorException: Conflicting method/path combination which is solved by having
[HttpGet("~/getsomething")]
[HttpGet("~/getothersomething")]
Answered By - Muhammad Arif
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.