Not a bug API error always return 400 if http code in range 100-400

truonglv

Well-known member
Affected version
2.2.0
After inspect code i see these lines:

Code:
if ($this->response->httpCode() < 400)
        {
            $this->response->httpCode(400);
        }

Why specific reason for that? In my extend want to throw 202 but seem that impossible for now.
 
The HTTP code is what really denotes an error (a 4xx or 5xx status code, see API error handling; returning a 200 for an error isn't correct). The contents give details on what the error is.

The short answer here is if you want to return something with a 2xx (or 3xx) code, you're not returning a response that represents an error, so you wouldn't return an error response from your controller. You can return any response code you want if you return an API result, for example.
 
Top Bottom