# |
Apr 19th 2017, 15:34 |
crazycoder |
Neon1024, https://gist.github.com/anonymous/f23de065af63b1388b64bd8332bdf031 |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
Perhaps you renderer is always assuming html |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
Then perhaps that could be why |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
As I think it’s supposed to pick a layout and template to match the extension |
# |
Apr 19th 2017, 15:34 |
crazycoder |
i am using a custom renderer ( i do not remember the reason ) :D |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
It’s the _outputMessage() method which confused me |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
Then changed the array data to match the json I wanted |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
if ($this->controller->request->is('json') andand strpos($this->controller->request->url, "api/v4") !== false) { |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
In the render() method I jsut added |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
I ended up copying it and just changing it a little to suit my needs |
# |
Apr 19th 2017, 15:32 |
Neon1024 |
I found the code in the ExceptionRenderer hard to follow |
# |
Apr 19th 2017, 15:32 |
crazycoder |
Neon1024, yes |
# |
Apr 19th 2017, 15:32 |
Neon1024 |
Hm, then perhaps it’s not hitting the controller action. Maybe the exception renderer doesn’t care about the headers and responds as html anyway |
# |
Apr 19th 2017, 15:32 |
crazycoder |
Neon1024, ^ |
# |
Apr 19th 2017, 15:32 |
crazycoder |
Neon1024, ? |
# |
Apr 19th 2017, 15:32 |
crazycoder |
no for not existant actions |
# |
Apr 19th 2017, 15:31 |
Neon1024 |
^ For your incorrect url I mean |
# |
Apr 19th 2017, 15:31 |
Neon1024 |
crazycoder: So if you use postman, and send a Content-Type: application/json header do you get a json error back? |
# |
Apr 19th 2017, 15:31 |
admad |
Erik: missing use statement |
# |
Apr 19th 2017, 15:30 |
crazycoder |
(yes i am using postman) |
# |
Apr 19th 2017, 15:30 |
crazycoder |
if i call an existant action i can work without XMLHttpRequest too |
# |
Apr 19th 2017, 15:30 |
crazycoder |
Neon1024, strange thing... if i do /api/notexists i will get an html output |
# |
Apr 19th 2017, 15:30 |
Erik180486 |
Cake\Event\Event given, called in /vendor/cakephp/cakephp/src/Event/EventManager.php |
# |
Apr 19th 2017, 15:29 |
Erik180486 |
anyone has any idea what this error means: Argument 1 passed to App\Controller\UsersController::beforeFilter() must be an instance of App\Controller\Event, instance of |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
https://www.getpostman.com/ |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
I’d hit stuff with Postman to check the api at least |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
Your setup sounds okay to me |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
As XMLHttpRequest isnt’ supported in Internet Explorer or something like that |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
Oh, are you not wrapping the Javascript in something? |
# |
Apr 19th 2017, 15:25 |
crazycoder |
Neon1024, ^^ |
# |
Apr 19th 2017, 15:24 |
crazycoder |
then i have seen that if i do not use XMLHttpRequest the component does not get the request....! |
# |
Apr 19th 2017, 15:23 |
crazycoder |
is this wrong ? |
# |
Apr 19th 2017, 15:23 |
crazycoder |
i have Router::extensions(['json', 'xml']); <-- in the main routes.php and $this->loadComponent('RequestHandler'); in the API appcontroller.php |
# |
Apr 19th 2017, 15:22 |
crazycoder |
on the main routes.php |
# |
Apr 19th 2017, 15:22 |
Neon1024 |
Ahok |
# |
Apr 19th 2017, 15:22 |
crazycoder |
inside the API routes.php NO but i have Router::extensions(['json', 'xml']); |
# |
Apr 19th 2017, 15:22 |
Neon1024 |
And the RequestHandlerComponent to allow auto-content type switching |
# |
Apr 19th 2017, 15:22 |
Neon1024 |
Router::extensions(['json']); |
# |
Apr 19th 2017, 15:22 |
Neon1024 |
Ah, perhaps you haven’t set the extensions in your routing? |
# |
Apr 19th 2017, 15:21 |
crazycoder |
so i think i must set headers |
# |
Apr 19th 2017, 15:21 |
crazycoder |
i get html output |