I am new to Spring Boot and Java so excuse my ignorance. I tried Googling but they all point me to Jackson errors which is what this is but I guess I am using Jackson implicitly by using @RequestBody
annotation in my controller (correct me if I am wrong). I have a Spring Boot controller that looks like this
@PostMapping(path = "/issues")
public Issue saveIssue(@RequestBody Issue issue) {
LOG.info("Saving issue");
return repository.save(issue);
}
The dto looks like
@Data
@NoArgsConstructor
@AllArgsConstructor
@DynamoDBTable(tableName = "")
public class Issue {
@DynamoDBHashKey
private String id;
@DynamoDBAttribute
private String type;
}
I'm using lombok
for @NoArgsConstructor
and @AllArgsConstructor annotations.
The issueRepository is just following simple repository pattern and just saving the issue using DynamoDBMapper
. I guess this doesn't matter because the code is not getting to this point anyway. It is failing to enter the control body because of invalid params or something.
Anyway, now I am making a post request that looks something like this:
curl --location 'localhost:8080/issues' \
--header 'Content-Type: application/json' \
--header 'Cookie: JSESSIONID=DC92631F992FC3EA38F7AF9C0080F856; hello=world; howdy=planet' \
--data '{
"id: "123"
"type": "code"
}'
I get the error
[ServerWebInputException: 400 BAD_REQUEST "Failed to read HTTP message"; nested exception is org.springframework.core.codec.DecodingException: JSON decoding error: Unrecognized field "id" (class <package>.issues.dto.Issue), not marked as ignorable; nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "id" (class io.atlassian.micros.snykeventforwarder.issues.dto.Issue), not marked as ignorable (0 known properties: ])
Why are there 0 known properties when my dto class clearly has id and type defined?