I'm running Craft CMS 2.6.2972 so I had to use the older Element API plugin.
I have downloaded the zip and then copied just the "elementapi" file in the zip to the plugin's folder.
Then I installed the plugin in the admin panel.
Then I made a file craft/config/elementapi.php with the contents
<?php
namespace Craft;
return [
'endpoints' => [
'news.json' => [
'elementType' => 'Entry',
'criteria' => ['section' => 'news'],
]
]
];
But if I hit the URL <myserver>/api/news.json
then I get the following error:
2017/05/12 17:31:47 [error] [exception.Craft\HttpException.404] exception 'Craft\HttpException' in C:\inetpub\wwwroot\craft\app\controllers\TemplatesController.php:59 Stack trace:
#0 [internal function]: Craft\TemplatesController->actionRender('api/news.json', Array)
#1 C:\inetpub\wwwroot\craft\app\framework\web\actions\CAction.php(109): ReflectionMethod->invokeArgs(Object(Craft\TemplatesController), Array)
#2 C:\inetpub\wwwroot\craft\app\framework\web\actions\CInlineAction.php(47): CAction->runWithParamsInternal(Object(Craft\TemplatesController), Object(ReflectionMethod), Array)
#3 C:\inetpub\wwwroot\craft\app\framework\web\CController.php(308): CInlineAction->runWithParams(Array)
#4 C:\inetpub\wwwroot\craft\app\framework\web\CController.php(286): CController->runAction(Object(CInlineAction))
#5 C:\inetpub\wwwroot\craft\app\framework\web\CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#6 C:\inetpub\wwwroot\craft\app\framework\web\CWebApplication.php(282): CController->run('render')
#7 C:\inetpub\wwwroot\craft\app\framework\web\CWebApplication.php(141): CWebApplication->runController('templates/rende...')
#8 C:\inetpub\wwwroot\craft\app\etc\web\WebApp.php(290): CWebApplication->processRequest()
#9 C:\inetpub\wwwroot\craft\app\framework\base\CApplication.php(185): Craft\WebApp->processRequest()
#10 C:\inetpub\wwwroot\craft\app\index.php(62): CApplication->run()
#11 C:\inetpub\wwwroot\public\index.php(14): require_once('C:\\inetpub\\wwwr...')
#12 {main} REQUEST_URI=/api/news.json
---
What might be wrong?
This is running on IIS and I've added .json to the mime types for the site.
This error is the same error as an unhandled link/route. So seems like it's not picking up the config or I have the wrong URL. The plugin did install ok.
/api/news.json
in the browser, pretty sure the endpoint should be defined as'api/news.json' => [
.