passbolt/passbolt_api · error · Cake\Http\Exception\BadRequestException
This is not a valid Ajax/Json request.
Error message
This is not a valid Ajax/Json request.
What it means
Guard in NotificationOrgSettingsGetController::get(): the email notification organization settings endpoint only serves JSON responses. It fires when the incoming request is not an Ajax/JSON request (e.g. a plain HTML GET, or missing the JSON Accept/Content-Type headers), rejecting it with HTTP 400 before any settings are read. The client must send the request with JSON headers as passbolt's API endpoints require.
Solutions
- Send the request with Accept: application/json and the json flag
- Use the API client configured for JSON requests
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at plugins/PassboltCe/EmailNotificationSettings/src/Controller/NotificationOrgSettings/NotificationOrgSettingsGetController.php:39 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/abdac8d1a043c2b7.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/EmailNotificationSettings/src/Controller/NotificationOrgSettings/NotificationOrgSettingsGetController.php:39
use Cake\Http\Exception\BadRequestException;
use Cake\Http\Exception\ForbiddenException;
use Cake\Utility\Hash;
use Passbolt\EmailNotificationSettings\Utility\EmailNotificationSettings;
class NotificationOrgSettingsGetController extends AppController
{
/**
* Handle Org Settings get request
*
* @return void
*/
public function get()
{
if ($this->User->role() !== Role::ADMIN) {
throw new ForbiddenException(__('You are not allowed to access this location.'));
}
if (!$this->request->is('json')) {
throw new BadRequestException(__('This is not a valid Ajax/Json request.'));
}
$configs = EmailNotificationSettings::get();
$flatten = Hash::flatten($configs);
$this->success(__('The operation was successful.'), $this->_formatForOutput($flatten));
}
/**
* Format the . delimited keys to snake_case
*
* @param array<string, mixed>|null $data The data to Format
* @return array<string, mixed> the formatted array
*/
private function _formatForOutput(?array $data = [])
{
$output = [];View on GitHub (pinned to 31c1bbc10f)