I have the most basic ManyToMany example, Project and Employee.
With a PUT request, I will project to employee and within the same function employee to project.
public Employee assignProjectToEmployee(Long empId, Long projectId) {
...
projectSet.add(project);
employee.setAssignedProjects(projectSet);
part of code Employee Entity:
@ManyToMany
@JoinTable(name = "youtube-dev-2-prod-coding-employee_project",
joinColumns = @JoinColumn(name = "employee_id"),
inverseJoinColumns = @JoinColumn(name = "project_id"))
@JsonManagedReference
private Set<Project> assignedProjects = new HashSet<>();
part of code Project Entity:
@JsonBackReference
@ManyToMany(mappedBy = "assignedProjects")
private Set<Employee> employeeSet = new HashSet<>();
✅When sending POST with Postman or Curl to save new Project, works fine.
🔴When sending POST with Postman or Curl to save new Employee, I get
"timestamp": "2025-08-28T17:12:19.998+00:00",
"status": 415,
"error": "Unsupported Media Type",
nota bene, when sending GET request for Employee, I would like to see all the Projects that employee is assigned on, and when sending GET request for Project, I would like to see all the Employees on that project. My question naturally is, why am I getting that 415 error
Code: https://github.com/beaverDamDemo/for-stackoverflow-question/tree/master (you would need to set the package in these files to make it work)
I tried examples from three different youtube tutorials and one example, taken from some published code on github