XML : Spring RESTful API not accepting XML params - Java

I am using Postman to post some data in XML on a restful API, but it gives,

  Required String parameter 'username' is not present    

here is the action,

  @ResponseBody  @RequestMapping(value = "/getToken", consumes = MediaType.APPLICATION_XML_VALUE, produces= MediaType.APPLICATION_XML_VALUE, method = RequestMethod.POST)  public Map<String,String> getToken(@RequestParam("username")String username, @RequestParam("password")String password)    

the XML I am sending is,

  <?xml version="1.0" encoding="UTF-8"?>  <root>  <username>someone@gmail.com</username>  <password>qweQWE123!@#</password>  </root>    

I am guessing the part where I am accepting the parameters (@RequestParam("username")String username, @RequestParam("password")String password) is the issue, to fix it I replaced it with,

  @RequestBody XMLObject object    

But then "Not Acceptable" error appeared.

No comments:

Post a Comment