yiisoft/yii2 · error · BadRequestHttpException

Invalid data received for GET parameter '{$this->formatParam

Error message

Invalid data received for GET parameter '{$this->formatParam}'.

What it means

Error "Invalid data received for GET parameter '{$this->formatParam}'." thrown in yiisoft/yii2.

Source

Thrown at framework/filters/ContentNegotiator.php:186

            if (\count($this->languages) > 1) {
                $response->getHeaders()->add('Vary', 'Accept-Language');
            }
            Yii::$app->language = $this->negotiateLanguage($request);
        }
    }

    /**
     * Negotiates the response format.
     * @param Request $request
     * @param Response $response
     * @throws BadRequestHttpException if an array received for GET parameter [[formatParam]].
     * @throws NotAcceptableHttpException if none of the requested content types is accepted.
     */
    protected function negotiateContentType($request, $response)
    {
        if (!empty($this->formatParam) && ($format = $request->get($this->formatParam)) !== null) {
            if (is_array($format)) {
                throw new BadRequestHttpException("Invalid data received for GET parameter '{$this->formatParam}'.");
            }

            if (in_array($format, $this->formats)) {
                $response->format = $format;
                $response->acceptMimeType = null;
                $response->acceptParams = [];
                return;
            }

            throw new NotAcceptableHttpException('The requested response format is not supported: ' . $format);
        }

        $types = $request->getAcceptableContentTypes();
        if (empty($types)) {
            $types['*/*'] = [];
        }

        foreach ($types as $type => $params) {

View on GitHub (pinned to 66f00d18a2)

When it happens

Trigger: Thrown at framework/filters/ContentNegotiator.php:186 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17). Data as JSON: /api/errors/c107565f98945c40. Report an issue: GitHub.