I've run into an issue where my .NET AWS Lambda function handler, which is set up to be accessible via the Lambda Function URL feature rather than API Gateway, is ignoring the APIGatewayHttpApiV2ProxyResponse I'm returning. It always responds with the original request body and the Content-Type
header value of application/json
.
I have exactly one line of code that can possibly write to the log in this function handler, followed by a straightforward response, not throwing any exceptions or anything:
var result = JsonConvert.DeserializeObject<DncInResponse>(responseString);
if (!result.success) LambdaLogger.Log("DNC callback failed: " + result.message);
return new APIGatewayHttpApiV2ProxyResponse() { Body = responseString, Headers = new Dictionary<string, string> { { "content-type", "text/xml" } }, StatusCode = 200, IsBase64Encoded = false };
(Putting aside the fact that I'm returning text/xml at the moment for what should be a JSON response... I tried several different response bodies, content types that match the body, and also capitalized Content-Type.)
My DNC callback failed
message appears in CloudWatch when I send a POST or GET request to the appropriate URL, so it's definitely executing the function handler up to the return statement.
I tried it with [assembly: LambdaSerializer(DefaultLambdaJsonSerializer)]
, [assembly: LambdaSerializer(Amazon.Lambda.Serialization.Json.JsonSerializer)]
as it's done here (except with APIGatewayHttpApiV2ProxyResponse as the response type) and with SourceGeneratorLambdaJsonSerializer
and the partial class and attributes as described here. I'm also using the latest version of every included NuGet package.