Hi all, Considering the discussions, I have implemented unified response message as follows.
*Error Response* { 'error': <error message> } *Success Response* { 'data' : [ ] } In both cases * HTTP status code *is sent in header. In success response what ever the response data/message is sent within the 'data'. Exact content of response 'data' will be defined in REST API documentations. On Tue, Aug 5, 2014 at 10:19 AM, Ayesha Dissanayaka <aye...@wso2.com> wrote: > Hi, > > @Udara: Noted your points. > @Dakshika: Since the one who makes the API call knows what it is for( APi > endpoints are well defined for their tasks), knowing request is succeeded > will be enough to distinguish. > > > On Mon, Aug 4, 2014 at 10:39 AM, Udara Liyanage <ud...@wso2.com> wrote: > >> Hi, >> >> @Ayesh HTTP status code should be sent as a HTTP header, not in the >> message body. >> @ Dakshika IMO Jaggery or any client can read the HTTP code from the >> response and detect whether it is a success. Then from client side it can >> display a success message. AFAIK there is no rule that a success message >> should or should not send in response. However IMO sending status code and >> success message is duplicating. >> >> >> On Fri, Aug 1, 2014 at 9:24 AM, Dakshika Jayathilaka <daksh...@wso2.com> >> wrote: >> >>> Hi, >>> >>> IMO we need to have "message" pram either its an error or success. >>> >>> because if you take status *202 Accepted* doesn't have mechanism to >>> shows exact accept scenario in detail. Then we can't go with generic >>> notification model on frontend and need to write custom implementations on >>> front end side. >>> >>> >>> >>> >>> >>> On Fri, Aug 1, 2014 at 3:43 AM, Ayesha Dissanayaka <aye...@wso2.com> >>> wrote: >>> >>>> Hi Udara, >>>> >>>> Thanks a lot for your suggestions. >>>> >>>> As I have mentioned earlier, 'code' is a standard HTTP Status Code. >>>> >>>>> "...idea is to derive the response from 'code' property. 'code' will >>>>> consist standard HTTP Status Codes." >>>>> >>>> >>>> Yes, we can drop "message" property from success response. >>>> >>>> Client can identify success or failure by http response code. IMO >>>>> having both code and message in success is duplicating. >>>> >>>> >>>> >>>> >>>> On Thu, Jul 31, 2014 at 9:46 PM, Udara Liyanage <ud...@wso2.com> wrote: >>>> >>>>> >>>>> Hi, >>>>> >>>>> How about sending http response code. Then if it is a 200, 201, 204 >>>>> etc then it can be considered as the success. Then there is no need of >>>>> sending a message like "something happens successfully" because we can >>>>> determine it by response code. >>>>> >>>>> For instance, when a resource with id abc is added successfully, >>>>> Response code is 201 with location header containing the URL to the >>>>> newly created resource abc >>>>> >>>>> We need a message format only when there is a error occurred. Response >>>>> only contains the back end error message. >>>>> >>>>> Client can identify success or failure by http response code. IMO >>>>> having both code and message in success is duplicating. I hope this is the >>>>> common REST way. >>>>> >>>>> >>>>> Touched, not typed. Erroneous words are a feature, not a typo. >>>>> >>>> >>>> >>>> >>>> -- >>>> *Ayesha Dissanayaka* >>>> Software Engineer, >>>> WSO2, Inc : http://wso2.com >>>> <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg> >>>> 20, Palmgrove Avenue, Colombo 3 >>>> E-Mail: aye...@wso2.com <ayshsa...@gmail.com> >>>> >>>> _______________________________________________ >>>> Dev mailing list >>>> Dev@wso2.org >>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>> >>>> >>> >>> _______________________________________________ >>> Dev mailing list >>> Dev@wso2.org >>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >>> >> >> >> -- >> >> Udara Liyanage >> Software Engineer >> WSO2, Inc.: http://wso2.com >> lean. enterprise. middleware >> >> web: http://udaraliyanage.wordpress.com >> phone: +94 71 443 6897 >> >> _______________________________________________ >> Dev mailing list >> Dev@wso2.org >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > *Ayesha Dissanayaka* > Software Engineer, > WSO2, Inc : http://wso2.com > <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg> > 20, Palmgrove Avenue, Colombo 3 > E-Mail: aye...@wso2.com <ayshsa...@gmail.com> > -- *Ayesha Dissanayaka* Software Engineer, WSO2, Inc : http://wso2.com <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg> 20, Palmgrove Avenue, Colombo 3 E-Mail: aye...@wso2.com <ayshsa...@gmail.com>
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev