Iām developing an app that performs a POST request to a certain route using ajax. The javascript that performs the request looks like this:
$.ajax({
type: āPOSTā,
url: ā/nextcloud/apps/app/saveā,
data: JSON.stringify(files),
contentType: āapplication/jsonā,
success: function(data) {
console.log(data);
}
});
While our routes looks like this:
return [
āroutesā => [
[ānameā => āpage#indexā, āurlā => ā/ā, āverbā => āGETā],
[ānameā => āsavefile#saveā, āurlā => ā/saveā, āverbā => āPOSTā]
]
];
and the controller looks like this
class saveFileController extends Controller {
private $userId;
public function __construct($AppName, IRequest $request, $UserId){
parent::__construct($AppName, $request);
$this->userId = $UserId;
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $files
*/
public function save(string $files) {
var_dump('we did it!');
return null;
}
}
But when the request is performed we recieve the error:
POST (url) 405 (Method Not Allowed)
What are we doing wrong here?
