i'm working on restful api end, , use json content type. , there 2 ways of performing error response know:
- http status code 200, , returning json should contain error code , error message.
- treat http status code part of our api, may pick http error code(4xx) corresponding error condition. , can include json document in payload includes sub-code , descriptive comment.
i want know 1 more idiom restful service?
generally speaking, not advocate returning 200. there failure scenarios match commonly accepted status codes. above, mentioned 403, deliver when access denied. , 500 typically issued web/app server when things go south. , 404 if either record not found resource.
so, advocate for:
- going @ least 200, 403, 404, 500
- providing verbose error details possible in json error response
- documenting every error code api might deliver - http status codes , every sub-condition error
Comments
Post a Comment