{"record":{"id":"abdac8d1a043c2b7","repo":"passbolt/passbolt_api","slug":"this-is-not-a-valid-ajax-json-request","errorCode":null,"errorMessage":"This is not a valid Ajax/Json request.","messagePattern":"This is not a valid Ajax/Json request\\.","errorType":"http","errorClass":"Cake\\Http\\Exception\\BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/EmailNotificationSettings/src/Controller/NotificationOrgSettings/NotificationOrgSettingsGetController.php","lineNumber":39,"sourceCode":"use Cake\\Http\\Exception\\BadRequestException;\nuse Cake\\Http\\Exception\\ForbiddenException;\nuse Cake\\Utility\\Hash;\nuse Passbolt\\EmailNotificationSettings\\Utility\\EmailNotificationSettings;\n\nclass NotificationOrgSettingsGetController extends AppController\n{\n    /**\n     * Handle Org Settings get request\n     *\n     * @return void\n     */\n    public function get()\n    {\n        if ($this->User->role() !== Role::ADMIN) {\n            throw new ForbiddenException(__('You are not allowed to access this location.'));\n        }\n        if (!$this->request->is('json')) {\n            throw new BadRequestException(__('This is not a valid Ajax/Json request.'));\n        }\n\n        $configs = EmailNotificationSettings::get();\n\n        $flatten = Hash::flatten($configs);\n\n        $this->success(__('The operation was successful.'), $this->_formatForOutput($flatten));\n    }\n\n    /**\n     * Format the . delimited keys to snake_case\n     *\n     * @param array<string, mixed>|null $data The data to Format\n     * @return array<string, mixed> the formatted array\n     */\n    private function _formatForOutput(?array $data = [])\n    {\n        $output = [];","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/EmailNotificationSettings/src/Controller/NotificationOrgSettings/NotificationOrgSettingsGetController.php#L21-L57","documentation":"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.","triggerScenarios":"Thrown at plugins/PassboltCe/EmailNotificationSettings/src/Controller/NotificationOrgSettings/NotificationOrgSettingsGetController.php:39 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send the request with Accept: application/json and the json flag","Use the API client configured for JSON requests"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}