error 415 Unsupported Media Type pour une application angular spring boot
Bonjour, je développe une application angular 8 Spring boot 2
j'essaye d'envoyer une requête post depuis un service angular mais je me heurte à une erreur 415 Unsupported Media Type
service angular
Code:
1 2 3 4
|
const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
const options = { headers: headers };
return this.http.post<Search>('/api/produitimmobilier/all', search, options).pipe(....... |
J 'ai essayé 2 paramètrage avec mon controlleur spring boot :
Code:
1 2 3 4 5
|
@RequestMapping(value = "/produitimmobilier/all",
method = RequestMethod.POST,consumes ="application/json")
@ResponseBody
public Search findAll(@RequestBody Search search){ |
et
Code:
1 2 3 4 5
|
@RequestMapping(value = "/produitimmobilier/all",
method = RequestMethod.POST,consumes = {"text/plain;charset=UTF-8", MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public Search findAll(@RequestBody Search search){ |
mais j'ai la même erreur. Pouvez vous m'aider ?
1 pièce(s) jointe(s)
Lors de l'insertion des données j'obtient error 415: Unsupported Media Type
Bonjour, je développe une application avec Spring boot
j'essaye d'envoyer une requête post depuis l'application ARC mais je me heurte à une erreur 415 Unsupported Media Type
voici mon controlleur
Pièce jointe 585440
voici mon entité Client
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
public class Client implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String nom;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFiliere() {
return filiere;
}
public void setFiliere(String filiere) {
this.filiere = filiere;
}
public Date getDateEnregistrement() {
return dateEnregistrement;
}
public void setDateEnregistrement(Date dateEnregistrement) {
this.dateEnregistrement = dateEnregistrement;
}
@JsonManagedReference
public Set<Emprunter> getEmprunter() {
return emprunter;
}
public void setEmprunter(Set<Emprunter> emprunter) {
this.emprunter = emprunter;
}
private String prenom;
private String email;
private String filiere;
private Date dateEnregistrement;
@OneToMany(mappedBy="client")
private Set<Emprunter> emprunter= new HashSet<>();
} |
voici mon entité Emprunter
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
public class Emprunter implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long idEmprunt;
private Date dateDebutEmprunt;
private Date dateDeRetourLivre;
private Date dateFinEmprunt;
public Long getIdEmprunt() {
return idEmprunt;
}
public void setIdEmprunt(Long idEmprunt) {
this.idEmprunt = idEmprunt;
}
public Date getDateDebutEmprunt() {
return dateDebutEmprunt;
}
public void setDateDebutEmprunt(Date dateDebutEmprunt) {
this.dateDebutEmprunt = dateDebutEmprunt;
}
public Date getDateDeRetourLivre() {
return dateDeRetourLivre;
}
public void setDateDeRetourLivre(Date dateDeRetourLivre) {
this.dateDeRetourLivre = dateDeRetourLivre;
}
public Date getDateFinEmprunt() {
return dateFinEmprunt;
}
public void setDateFinEmprunt(Date dateFinEmprunt) {
this.dateFinEmprunt = dateFinEmprunt;
}
@JsonBackReference
public Client getClient() {
return client;
}
public void setClient(Client client) {
this.client = client;
}
@JsonBackReference
public Livre getLivre() {
return livre;
}
public void setLivre(Livre livre) {
this.livre = livre;
}
@ManyToOne
@JoinColumn(name="IdClient")
private Client client;
@ManyToOne
@JoinColumn(name="IdLivre")
private Livre livre;
} |
aider moi a resoudre le problème s'il vous plais