wood burning stoves 2.0*
The moose likes Web Services and the fly likes re: REST return a response status of 406 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "re: REST return a response status of 406 " Watch "re: REST return a response status of 406 " New topic
Author

re: REST return a response status of 406

Mark Curlette
Ranch Hand

Joined: May 26, 2011
Posts: 46

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

Joined: Jan 10, 2002
Posts: 61457
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mark Curlette
Ranch Hand

Joined: May 26, 2011
Posts: 46

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

Joined: Jan 10, 2002
Posts: 61457
    
  67

 
 
subject: re: REST return a response status of 406