Lambda Function not returning all properties in a response via function URL.

0

I have a Lambda function class in dotnet 8, as shown in the code excerpt below. However, when I deploy this to AWS Lambda and test it via Post Man, I get only the ID of the product, not the name and the description., and I don't understand why given I am returning the entire response object.

public class Function
{
    public CreateProductResponse FunctionHandler(CreateProductRequest input, ILambdaContext context)
    {
        var response = new CreateProductResponse();
        response.Id = Guid.NewGuid().ToString(); // Only Id is returned to the API call.
        response.Name = input.Name;
        response.Description = input.Description;
        return response; // Entire response returned but Name and Description missing.
    }

    public class CreateProductRequest
    {
        public string? Name { get; set; }
        public string? Description { get; set; }
    }

    public class CreateProductResponse
    {
        public string? Id { get; set;}
        public string? Name { get; set;}
        public string? Description { get; set;}

    }
}

Screen shot:

Enter image description here

질문됨 한 달 전122회 조회
1개 답변
1

It seems that you are returning in the response whatever you got in the request. Did you pass the correct input? I would suggest to print the input object to make sure it has the values you want.

profile pictureAWS
전문가
Uri
답변함 한 달 전
  • Using the Mock Lambda Test Tool and running the debugger in Visual Studio all of the values in the response are return. However, using the Function Url after the code is deployed then I only see the Id.

    This is the result from the Lambda Test Tool: [{"Id":"94e502ad-e750-4927-afdd-3e4d34de65f4","Name":"BMW","Description":"Car"}]

  • I added an image of the execution to the main question. It shows all of the values when using the Lambda Test Too.

  • I recommend that you add a printout at the beginning of the handler to check the values in the event object.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠