Aws-lambda-dotnet: Payload for Lambda, from APIGatewayProxyRequest object (works in node)

Created on 18 May 2017  ·  3Comments  ·  Source: aws/aws-lambda-dotnet

I have a query on what should have been something really simple.

We have a need for writing our Lambda in .Net Core (C#) which is using a API Gateway resource and were trying to get custom variables created either from the Custom Authorizer or directly from the body mapping template attached to the API Gateway's resource (on the Integration Request).

The problem we ran into was that through node you can access the 'event' parameter which would contain the entire json payload, meaning you could get your new custom variable like so:
event.requestContext.authorizer.customKey or event.requestContext.context.customKey.

The problem is that there is no way to get these variables from within the C# code, using the [APIGatewayProxyRequest] request object. I have chatted with some engineers from AWS (we have a business plan), who have confirmed (after 3 or 4 people go involved) that there is no obvious or possible way of getting this entire payload from the request object for interrogation, through C#.

This was a problem with our particular case, as we could then, not access the any custom variables, meaning we need to change plans.

I find it really strange how it can be achievable within node but not catered for in C#?

A Stack Overflow question what would help with an example, can be found here:
http://stackoverflow.com/questions/43990385/aws-lambda-c-sharp-accessing-custom-context

Can this be confirmed?

@normj

feature-request

Most helpful comment

Yes, we do need to expand APIGatewayProxyRequest to get access to the custom authorizer.

A work around till then is have your Lambda function take in a System.IO.Stream instead of APIGatewayProxyRequest. Then you have access to the original JSON which you can parse yourself. You can grab the information you need from that JSON and then deserialize JSON to APIGatewayProxyRequest as well.

All 3 comments

Yes, we do need to expand APIGatewayProxyRequest to get access to the custom authorizer.

A work around till then is have your Lambda function take in a System.IO.Stream instead of APIGatewayProxyRequest. Then you have access to the original JSON which you can parse yourself. You can grab the information you need from that JSON and then deserialize JSON to APIGatewayProxyRequest as well.

Closing is this is a duplicate of https://github.com/aws/aws-lambda-dotnet/issues/98

has this feature been added? if yes, could i get a link to some documentation around it?

Was this page helpful?
0 / 5 - 0 ratings