Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

re: REST return a response status of 406

 
Mark Curlette
Ranch Hand
Posts: 46
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am new to REST , and I am trying to figure out why it gives me a return status code of 406.
Please help me to shed some light into this.

I have create a web dynamic project called RestSimpleApp. It contains three sample programs in three different packages as follow :




I was able to view the result of my order through the web browser as http://localhost:8080/RestSimpleApp/rest/orders. However, I got the return reponse status of 406 when I tried to call it from a client program which I have created in another web dynamic project as follow




I am awared that I may miss some important things but I could not figure out, so please help me if you can.

Thanks so much in advance,

Tom

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the Accept header on the request? 406 usually means that you've asked for a media type that isn't possible to generate.

It looks look your service is limited to XML and JSON.
 
Mark Curlette
Ranch Hand
Posts: 46
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much Bear. It worked when I change my request to MediaType.APPLICATION_XML or MediaType.APPLICATION_JSON. I remember now to pay attention to the accept header of the request.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic