2015-11-26 1 views
0

Je tente d'exécuter projet https://github.com/bava/springrest-book/tree/master/Chapter4/final/quick-poll-ch4-finalHttp 415 erreur non pris en charge Type de support JSON POST

Mon contrôleur est https://github.com/bava/springrest-book/blob/master/Chapter4/final/quick-poll-ch4-final/src/main/java/com/apress/controller/PollController.java

changer seulement je l'ai fait utilise Lombok (pas en classe de sondage pour l'instant)

@ToString 
@Entity 
public class Option { 
    @Id 
    @GeneratedValue 
    @Column(name="OPTION_ID") 
    @Getter 
    @Setter 
    private Long id; 

    @Column(name="OPTION_VALUE") 
    @Getter 
    @Setter 
    private String value; 
} 

Je reçois erreur

{"timestamp":1448542212469,"status":415,"error":"Unsupported Media Type","exception":"org.springframework.web.HttpMediaTypeNotSupportedException","message":"Content type 'text/plain;charset=UTF-8' not supported","path":"/polls"} 

Lors de l'envoi d'une requête POST

{ 
    "question": "Who will win SuperBowl this year?", 
    "options": [ 
         {"value": "New England Patriots"}, 
         {"value": "Seattle Seahawks"}, 
         {"value": "Green Bay Packers"}, 
         {"value": "Denver Broncos"}] 
} 

Je ne sais pas ce que je fais mal enter image description here Remarque: Être fonctionne bien (peut essayer seulement 0 entrées pour l'instant)

Répondre

3

Vous devez Spécifiez le Content-type pour la demande que vous faites, comme indiqué ci-dessous.

enter image description here