# Rendering suddenly throwing up "Missing Template" issue

**URL:** <https://discourse.cakephp.org/t/rendering-suddenly-throwing-up-missing-template-issue/1835>\
**Category:** Need Help\
**Created:** [January 6, 2017, 5:06pm UTC](https://discourse.cakephp.org/t/rendering-suddenly-throwing-up-missing-template-issue/1835 "2017-01-06T17:06:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SharonGilmore](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/sharongilmore/32/423_2.png) [@SharonGilmore](https://discourse.cakephp.org/u/SharonGilmore)\
**Post date:** [January 6, 2017, 5:06pm UTC](https://discourse.cakephp.org/t/rendering-suddenly-throwing-up-missing-template-issue/1835/1 "2017-01-06T17:06:30Z")

</div>

I’m having a problem with rendering json in my app. It was working fine earlier, and I don’t think I changed the relevant code, but I must have changed something else which caused this to happen!

(I’m just getting to grips with Cake 3, having used Cake 2 for a long time, so I’m also vaguely aware that there’s maybe a better way to handle requests and return json, but I haven’t figured that out yet.)

Basically, I’m trying to render a JSON response. In my NewsController, I have the following (in a function called imageUpload):

```
	$this->viewBuilder()->layout('json');

```

This layout is basically blank (just contains \<?= $this-\>fetch('content') ?\>).

The function then does what it needs to do, and finally attempts to render the result like this:

```
	$result = array('success' => 1, 'filename' => $filename);
	$this->set('result', json_encode($result));
	$this->render('json_result');

```

As I said, this used to work, but now I’m getting the following error message:

`Template file "Admin\News\json\json_result.ctp" is missing.`

The file json\_result.ctp is, and has always been, in the folder “Admin\News\json\_result.ctp” (i.e. there’s never been a ‘json’ subfolder to contain the file).

Obviously I could fix this by creating the json subfolder and moving the file into it, but it’s being used in other places and I don’t want to break those, plus I don’t like to do things like that without understanding why!

Can anyone shed any light on this?

Thanks!

---

<div class="post-metadata">

**Author:** ![sourjya](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/sourjya/32/422_2.png) [@sourjya](https://discourse.cakephp.org/u/sourjya)\
**Post date:** [August 21, 2017, 3:52am UTC](https://discourse.cakephp.org/t/rendering-suddenly-throwing-up-missing-template-issue/1835/2 "2017-08-21T03:52:06Z")

</div>

Hi,  
I don’t have an in-depth answer for you - but I faced similar situation with Ajax responses. In my projects I simply create the ajax folder and put a blank ctp file matching the name of the method in there - and so far life has been easy 😉 Nothing broke… that’s for sure.

I’d say, please go ahead and create the json folder and move the file under it.

Cheers.

---

<div class="post-metadata">

**Author:** ![xaphalanx](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/xaphalanx/32/575_2.png) [@xaphalanx](https://discourse.cakephp.org/u/xaphalanx)\
**Post date:** [August 21, 2017, 3:51pm UTC](https://discourse.cakephp.org/t/rendering-suddenly-throwing-up-missing-template-issue/1835/3 "2017-08-21T15:51:36Z")

</div>

Access the url using the “.json” extension

/YourController/yourAction.json.

---

<div class="post-metadata">

**Author:** ![sourjya](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/sourjya/32/422_2.png) [@sourjya](https://discourse.cakephp.org/u/sourjya)\
**Post date:** [August 24, 2017, 2:21am UTC](https://discourse.cakephp.org/t/rendering-suddenly-throwing-up-missing-template-issue/1835/4 "2017-08-24T02:21:57Z")

</div>

True - you should be accessing using the .json extension to trigger the related view.
