# getFlash() from Cake/Http/ServerRequest

**URL:** <https://discourse.cakephp.org/t/getflash-from-cake-http-serverrequest/10028>\
**Category:** Need Help\
**Created:** [December 27, 2021, 10:30am UTC](https://discourse.cakephp.org/t/getflash-from-cake-http-serverrequest/10028 "2021-12-27T10:30:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mvojwe](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mvojwe](https://discourse.cakephp.org/u/mvojwe)\
**Post date:** [December 27, 2021, 10:30am UTC](https://discourse.cakephp.org/t/getflash-from-cake-http-serverrequest/10028/1 "2021-12-27T10:30:57Z")

</div>

I’m following the tutorial of the [Authorization plugin](https://book.cakephp.org/authorization/2/en/middleware.html#add-a-flash-message-after-being-redirected-by-an-unauthorized-request) and Im facing issues at

> $request-\>getFlash()-\>error( ‘You are not authorized to access that location’ );

I get the following message:

> Method “getFlash()” does not exist, BadMethodCallException

Using get\_class() I know $request is an instance of Cake/Http/ServerRequest and according to the [API](https://api.cakephp.org/4.2/class-Cake.Http.ServerRequest.html#getFlash()) the method should exist.

Also, looking into vendor/cakephp/cakephp/src/Http/ServerRequest.php I cant find that method.

PD: using CakePHP v4.1.7

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [December 27, 2021, 11:53am UTC](https://discourse.cakephp.org/t/getflash-from-cake-http-serverrequest/10028/2 "2021-12-27T11:53:54Z")

</div>

You are looking at the API Doc for CakePHP 4.2  
Since you are on 4.1.7 you don’t have that method yet because it was added in 4.2  
See [4.2 Migration Guide - 4.x](https://book.cakephp.org/4/en/appendices/4-2-migration-guide.html#http)

---

<div class="post-metadata">

**Author:** ![mvojwe](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mvojwe](https://discourse.cakephp.org/u/mvojwe)\
**Post date:** [December 27, 2021, 12:09pm UTC](https://discourse.cakephp.org/t/getflash-from-cake-http-serverrequest/10028/3 "2021-12-27T12:09:52Z")

</div>

Thanks for the fast response! I will migrate to the last version.
