'I am getting unsupported media type error for restful web service with post request as XML
Post method:
@RequestMapping(value = "/reverseFeed/customerStatus", method = RequestMethod.POST)
public CustomerNewCKYCStatusResponse reverseFeedCustomerStatus(@RequestBody CustomerNewCKYCStatusRequest customerNewCKYCStatusRequest) throws Exception {
log.info("Calling reverse feed api to set CKYC status response of user");
CustomerNewCKYCStatusResponse customerNewCKYCStatusResponse = ckycReverseUploadService.setCustomerCKYCStatus(customerNewCKYCStatusRequest);
return customerNewCKYCStatusResponse;
}
POJO which I am giving for this request:
public class CustomerNewCKYCStatusRequest {
private int custNo;
private String name;
private String country;
public CustomerNewCKYCStatusRequest() {
}
public CustomerNewCKYCStatusRequest(int custNumber, String name, String country) {
this.custNo = custNumber;
this.name = name;
this.country = country;
}
public int getCustNo() {
return custNo;
}
public void setCustNo(int custNo) {
this.custNo = custNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
}
Request Body which I am setting in the postman request:
<?xml version="1.0" encoding="UTF-8"?>
<customer>
<country>United States</country>
<custNo>100</custNo>
<name>Google</name>
</customer>
I am setting header as text/xml, tried using application/xml as well. I also tried to set consumes = {MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE} in the method. Nothing seems to be working now.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
