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

asked 12 days ago94 views
1 Answer
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
EXPERT
Uri
answered 12 days ago
  • 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.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions