'Problem with my response in Postman : i keep receiving the response in xml format
I keep receiving my response in xml i dont know why and i want it to be by default json, once i used jackson-dataformat-xml but i delete it and update it the project (maven -->update project) and i tried deleting all the dependecies in my .m2 folder in my pc but still i keep having it in my .m2 when i reinstall all the dep i dont know why (btw i know there is a solution in postman where i can update the accept in the headers to application/json) here my pom.xml
Solution 1:[1]
Here you don't want to change any dependencies with pom.xml file.
--> Problem is with postman, you have change the postman result as XML to JSON then you will get the response as JSON. Please check the below image to change the settings in Postman.
Thank You
Solution 2:[2]
add this to specific api controller:
produces = MediaType.APPLICATION_JSON_VALUE
like here:
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public UserDto getUser(@Valid @PathVariable long id) {
return mapper.fromUser(service.getById(id));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Santil |
Solution 2 | husnitdin |