Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP REST Authorization issue on POST and PUT (I get 404)
    text
    copied!<p>I'm developing a REST api for a application, and everething went fine up until now... I'm building a header with login data, GET and DELETE work fine but when I try to send a PUT or POST request I get 404... When authorization is off (i.e., I do not check it in cake) everything works fine.</p> <p>Here's the controller code: </p> <pre><code>class SitesController extends AppController { var $uses = array("Site"); var $name = 'Sites'; var $scaffold; var $components = array('RequestHandler','Security'); function beforeFilter() { $this-&gt;Security-&gt;loginOptions = array( 'type'=&gt;'basic' ); $this-&gt;Security-&gt;loginUsers = array( 'lukasz'=&gt;'blabla', 'test'=&gt;'test' ); $this-&gt;Security-&gt;requireLogin(); } function index() { $sites = $this-&gt;Site-&gt;find('all'); $this-&gt;set(compact('sites')); } function view($id) { $site = $this-&gt;Site-&gt;findById($id); $this-&gt;set(compact('site')); } function add() { if($this-&gt;data != null) { $this-&gt;Site-&gt;create(); if($this-&gt;Site-&gt;save($this-&gt;data)) { $message = array('Deleted'); } else { $message = $this-&gt;data; } $this-&gt;set(compact("message")); } } function edit($id) { $this-&gt;Site-&gt;id = $id; if ($this-&gt;Site-&gt;save($this-&gt;data)) { $message = array('Saved'); } else { $message = array('Error'); } $this-&gt;set(compact("message")); } function delete($id) { if($this-&gt;Site-&gt;delete($id)) { $message = array('Deleted'); } else { $message = array('Error'); } $this-&gt;set(compact("message")); } } </code></pre> <p>And here's how I send requests:<br> <a href="http://bin.cakephp.org/view/165115685" rel="nofollow noreferrer">http://bin.cakephp.org/view/165115685</a><br> <a href="http://bin.cakephp.org/view/1477117088" rel="nofollow noreferrer">http://bin.cakephp.org/view/1477117088</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload