Skip to content

Use a POJO instead of String in "body" ApiGatewayRequest field #1

@destebanm

Description

@destebanm

Hi!

I have an issue related with the class ApiGatewayRequest:

Reading your comment about "body" field

if you require parameters from a transformed request body (e.g. POST payload)
then you'll need to define your POJO matching the expected deserialised object here
in place of the 'body' String property

I understand that
private String body;

 public String getBody() {
    return body;
}

public void setBody(String body) {
    this.body = body;
}

could be replaced by i.e Customer (Customer is my POJO)

private Customer body;

 public Customer getBody() {
    return body;
}

public void setBody(Customer body) {
    this.body = body;
}

Nevertheless, if i do that, i get the next error:

RuntimeException","stackTrace":[],"cause":{"errorMessage":"com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class com.naevatec.iot.pojos.Customer] from String value ('{\n "firstName":"Hello",\n "lastName":"World"\n}'); no single-String constructor/factory method\n at [Source: lambdainternal.util.NativeMemoryAsInputStream@3e57cd70; line: 1, column: 864] (through reference chain: com.naevatec.iot.pojos.apigateway.ApiGatewayRequest["body"])","errorType":"java.io.UncheckedIOException","stackTrace":[],"cause":{"errorMessage":"Can not instantiate value of type [simple type, class com.naevatec.iot.pojos.Customer] from String value ('{\n "firstName":"Hello",\n "lastName":"World"\n}'); no single-String constructor/factory method\n at [Source: lambdainternal.util.NativeMemoryAsInputStream@3e57cd70; line: 1, column: [TRUNCATED]

Were you be able to get working it?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions