1

I am trying to transfer an asp.net core web api to my first AWS HTTP API. I have hosted the asp.net core web api project as a lambda function, and trying to match the endpoints through the API gateway. I can access the default endpoints though my API gateway. i.e. the following endpoint can be accessed through my api gateway successfully.

[Route("api/[controller]")]
    public class ValuesController : ControllerBase
    {
        // GET api/values
        [HttpGet]
        public IEnumerable<string> Get()
        {
            return new string[] { "value10", "value200" };
        }
...
}  

enter image description here

But, I get a 404 not found exception if I try to access some method with a Route attribute. e.g.

[Route("api/[controller]")]
    [ApiController]
    public class ReportsController : ControllerBase
    {
        // GET api/values
        [HttpGet, Route("GetReports")]
        public IEnumerable<string> GetReports()
        {
            return new string[] { "value100", "value2000" };
        }
    }

with the following mapping enter image description here

What am I doing wrong here?

thanks,

BZKN
  • 1,499
  • 2
  • 10
  • 25
nilarya
  • 99
  • 1
  • 16
  • 1
    What is your lambda initialization function? – John Glenn Jan 29 '22 at 21:44
  • I am using the serverless.AspNetCoreWebAPI template to create my lambda function. If I understood your question correctly, my LambdaEntryPoint class extends from Amazon.Lambda.AspNetCoreServer.APIGatewayHttpApiV2ProxyFunction – nilarya Jan 29 '22 at 21:56
  • Ah, I think I figured out the problem, I was missing the package reference of Amazon.Lambda.AspNetCoreServer. now the GetReports route resolves, thanks @JohnGlenn for pointing at the right direction! – nilarya Jan 29 '22 at 22:05
  • You're welcome! I'm glad you got it working. – John Glenn Jan 29 '22 at 23:20

0 Answers0