Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APIGatewayProxyRequest not getting populated after dotnet core upgrade from 1.0 to 2.1

I am currently working on to upgrade dotnet core framework version from 1.0 to 2.1 of an existing product. The UI of the same is made in Angular which makes service calls to AWS Lambdas (made using dotnet core) for all the requirements. User data is stored in AWS Cognito and every time a service call is made it first gets verified by fetching data from Cognito. This part stopped working after the framework upgrade.

The following lines of code stopped fetching data:

if (!HttpContext.Items.Keys.Contains("APIGatewayRequest"))
{
    //Log error
}
HttpContext.Items["APIGatewayRequest"] as APIGatewayProxyRequest;

Custom api gateway authorizer is used for Cognito and also HttpContext is used inside a controller.

The following image shows the Request.HttpContext structure for me: enter image description here

Any information around this issue will be great.

like image 271
Arup Chaudhury Avatar asked Oct 31 '25 06:10

Arup Chaudhury


1 Answers

Finally, after trying desperately for a couple of days, I got the resolution. In the newer version of DotNet Core the value of the HttpContext key got changed from "APIGatewayRequest" to "LambdaRequestObject" causing all the pain. And the code was using the value directly from a constant declared inside the project and was not using the constant "AbstractAspNetCoreFunction.LAMBDA_REQUEST_OBJECT" provided by the framework.

like image 101
Arup Chaudhury Avatar answered Nov 02 '25 23:11

Arup Chaudhury



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!