how to send JSON data with server error response code 500
        Posted  
        
            by kapil.israni
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by kapil.israni
        
        
        
        Published on 2010-06-14T19:47:48Z
        Indexed on 
            2010/06/14
            19:52 UTC
        
        
        Read the original article
        Hit count: 384
        
I wanted to know if theres a way to send a JSON data along with HTTP response code 500. Basically I want my rest client to know that there is some error on the backend and along with it send a JSON error data structure like this.
{"error" : [
          {"code": "1001", "desc": "Some error description"},
          {"code": "1002", "desc": "Some other error description"}
           ]
}
This is using the following java stack = Java 6/JAX-RS/Jersey/Tomcat
If not, then is there a way to send a custom response code along with JSON data. Basically looking from JAX-RS API it looks that you can only send JSON data along with 200 OK??
Any thoughts?? I am guessing RESTEasy would be the same, right??
© Stack Overflow or respective owner