Where do I override REST error messages?

Hi,

I’m working on a REST API and I’m trying to customize the error response. By default, if I use the wrong credentials when submitting a request I see this:


{

  "name": "Unauthorized",

  "message": "You are requesting with an invalid credential.",

  "code": 0,

  "status": 401

}

Where and how can I remove the "code" and "name" lines?

Thanks.

Hi Littlebob!

You can change your response using the event “before send”. I’m sending you a link describing how it works (Customizing Error Response Format).

http://www.yiiframework.com/doc-2.0/guide-runtime-handling-errors.html

Best regards,

Ricardo

Thank you.