Rest Api Error Handling In Modules

Hi All,

I’ve been working on REST API as modules. I can get errors and exceptions inside the rest controllers as json/xml. But when ever try to access a invalid entry point, Im getting a html respone saying not found exception.

My api url is like

localhost.backend/api/v1/invalidentrypoint

Here api is a module and v1 is another module which nested indside api module.

Please help.

Hello,

that request should return a 404 status so you won’t need to read the response, which I think it is correct.

bye,

Giovanni.

Yeah, But it should return a proper REST API response in json/xml as shown in YII 2.0 guid

HTTP/1.1 404 Not Found

Date: Sun, 02 Mar 2014 05:31:43 GMT

Server: Apache/2.2.26 (Unix) DAV/2 PHP/5.4.20 mod_ssl/2.2.26 OpenSSL/0.9.8y

Transfer-Encoding: chunked

Content-Type: application/json; charset=UTF-8

{

"type": "yii\\web\\NotFoundHttpException",


"name": "Not Found Exception",


"message": "The requested resource was not found.",


"code": 0,


"status": 404

}

but instead of this I’m recieving a default site error page :(

you can use RestClient firefox addon to debug it more.

But am excited how do you nest them?