![]() ![]() Empty JSON array/object if no record found."error" object in JSON result if something goes wrong.Instead of this you may return 200 HTTP code with some options: Is it possible to receive an empty web-page with 200 as HTTP result, right? Because URI resource is found and was handled by the HTTP server. If the HTTP request physically was performed successfully it should always return 200 code, regardless is the record(s) found or not. (HTTP)Īnd the list may continue with '500 Server error" (an Apache/Nginx HTTP thrown error or a business constraint error in REST) or other HTTP errors etc.įrom the code, it's hard to understand what was the failure reason, a HTTP (transport) failure or a REST (logical) failure. Wrong access permissions configured on the server. ![]() Browsers can handle it by asking the user/password. REST is a concept/approach, and its output is a business/logical result, while HTTP result code is a transport one.įor example, returning "404 Not found" when you call /users/ is confuse, because it may mean: A REST call is done using a Hypertext Transfer Protocol request and it works at a lower level than invoked REST method itself. HTTP return codes are related to the HTTP Request itself. However, I saw many implementations mixing them, and many developers may not agree with me. It is wrong to mix HTTP status codes and REST status codes. a lot of answers trying to guess, argue and standardize what is the best return code for a successful HTTP request but a failed REST call. ![]()
0 Comments
Leave a Reply. |