Convert Xml request to Object Spring Boot

Created a spring boot rest service which accepts XML as a request and converts it into object and then inserts it into database.
I used Jackson dataformat dependency for directly converting the xml request to object but getting an error .

The controller class is as follows

@RequestMapping(value = "/getRequestData",method=RequestMethod.POST,
        produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE},consumes={MediaType.APPLICATION_XML_VALUE})
    public ResponseEntity<?> putDataIntoDatabase(@RequestBody FirstRequestorBean bean) {

        logger.info(bean.getId());
        return new ResponseEntity<String>(HttpStatus.OK);
    }

and bean class

public class FirstRequestorBean {


    private String name;
    private String id;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }



}

the xml passed here is

<?xml version="1.0" encoding="UTF-8"?>
<FirstRequestorBean>
    <name>Akhil</name>
    <id>1</id>
</FirstRequestorBean>  

getting a Unsupported Media Type exception.

can someone point out how to resolve the issue

Your Post request will have a “content-type” which needs to match up to the “consumes” parameter for your request mapping.

For XML there are two types “application/xml” and “text/xml” it is good practice to accept both, (MediaType.APPLICATION_XML_VALUE & MediaType.TEXT_XML_VALUE).

Additionally you have:
produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE} this is your return type, you only need to define this once you are actually returning something, seeing as are only setting a status code then this should be removed.