Skip to content

UPDATE: I@RequestBody with Custom Object in PostMapping is not working.  #316

Closed
@patvin80

Description

@patvin80

UPDATE: I found it. This may be related, but I discovered that the error does not lie with the POST itself, but with the inability of Jackson to map / parse the incoming Domain object.

If I replace

    @RequestMapping(path = "/domain", method = RequestMethod.POST)
    public Domain createDomain(@RequestBody Domain domain) {
        logger.info("Domain: " + domain.getDomainName());
        return new Domain(domain.getDomainName(), domain.getReputation());
    }

with

    @RequestMapping(path = "/domain", method = RequestMethod.POST)
    public Domain createDomain(@RequestBody String domainString) throws IOException {
        logger.info(domainString);
        ObjectMapper mapper = new ObjectMapper();
        Domain domain = mapper.readValue(domainString, Domain.class);
        return domain;
    }

i.e. handle the parsing within the call itself, things work just fine. It seems that there is something with the parsing of a @RequestBody when specifying an object. I'll see if I can repeat that that with "normal" Spring Boot.

Originally posted by @chadothompson in #259 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions