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

質問済み 1ヶ月前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
回答済み 1ヶ月前
  • 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.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ