# request-\>getData isnt working on cakephp3.6

**URL:** <https://discourse.cakephp.org/t/request-getdata-isnt-working-on-cakephp3-6/4981>\
**Category:** Uncategorized\
**Created:** [September 22, 2018, 12:03pm UTC](https://discourse.cakephp.org/t/request-getdata-isnt-working-on-cakephp3-6/4981 "2018-09-22T12:03:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagguy](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@jagguy](https://discourse.cakephp.org/u/jagguy)\
**Post date:** [September 22, 2018, 12:03pm UTC](https://discourse.cakephp.org/t/request-getdata-isnt-working-on-cakephp3-6/4981/1 "2018-09-22T12:03:09Z")

</div>

I upgraded my cakephp to ver 3.6 . I cant rewrite this code that worked in cakephp3.2 to make it work in 3.6 to parse get data for a search

Whats going on here as the message doesnt make sense? I tried getParam and I get same error?

```auto
 Accessing routing parameters through `getData` will removed in 4.0.0. Use `getParam()`    

if ($this->request->is('post')) {

     if ($this->request->getData('search')!=null ) { 
               $filter_url['controller'] = $this->request->getParam('controller');
               $filter_url['action'] = $this->request->getParam('action');
                $filter_url['page'] = 1;
        foreach($this->request->getData as $name => $value){ //error here

            if($value){
                $filter_url[$name] = urlencode($value);

            }
                }
            return $this->redirect($filter_url);

          }//if isset     

    } // if post

```

---

<div class="post-metadata">

**Author:** ![mds2018](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@mds2018](https://discourse.cakephp.org/u/mds2018)\
**Post date:** [September 23, 2018, 11:02pm UTC](https://discourse.cakephp.org/t/request-getdata-isnt-working-on-cakephp3-6/4981/2 "2018-09-23T23:02:59Z")

</div>

> [@jagguy](#):
>
> $this-\>request-\>getData

I re-wrote your code. The code I wrote should help you understand what the problem was.

if ($this-\>request-\>is(‘post’)) {

```
	$search = $this->request->getData('search');
	
	if (!empty($search)) {
		$filter_url['page'] = 1;
		$filter_url['action'] = $this->request->getParam('action');
		$filter_url['controller'] = $this->request->getParam('controller');
		$requestData = $this->request->getData(); //function not a property defined in an object
		/*
			You were trying to get the data from a property in an object instead of calling the 
			CakePhp pre-defined function that does that.
			
			You could have:				
			foreach($this->request->getData() as $key => $value) {
					
			}
			
			Or define a variable to hold the data like I have done and then run the foreach
		*/
		foreach($requestData as $name => $value) {
			if($value) {
				$filter_url[$name] = urlencode($value);
			}
		}
		
		unset($requestData);
		
		return $this->redirect($filter_url); 
	}
}

```

I hope it helps.
