I have the following setup:
My controller:
@RequestMapping("/project") @RestController public class ProjectController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired ProjectService projectService; @CrossOrigin @PostMapping(value = "/createProject") public ResponseEntity createProject(@RequestBody ProjectDto projectJsonString) { return ResponseEntity.ok(HttpStatus.OK); } } In my .service.ts:
this.http.post('http://localhost:8080/project/createProject', JSON.stringify(project)). subscribe( (res) => { this.logger.info('Response: ' + res); }); My Dto:
public class ProjectDto { private String projectName; private String projectNumber; private String projectArea; private String managerName; private String managerShorthand; } But when I build the app to a jar-file and execute it I get the following error when the api-call is executed:
HttpErrorResponse {headers: HttpHeaders, status: 415, statusText: "OK", url: "http://localhost:8080/project/createProject", ok: false, …} error: error: "Unsupported Media Type" message: "Content type 'text/plain;charset=UTF-8' not supported" path: "/project/createProject" status: 415 timestamp: "2018-12-10T21:41:26.036+0000" and the same thing happens when I curl it. Can someone tell me what I am doing wrong?
nameinstead ofvalue, thanks for that!