Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractBrowser.php

function AbstractBrowser::jsonRequest

Converts the request parameters into a JSON string and uses it as request content.

File

vendor/symfony/browser-kit/AbstractBrowser.php, line 164

Class

AbstractBrowser
Simulates a browser.

Namespace

Symfony\Component\BrowserKit

Code

public function jsonRequest(string $method, string $uri, array $parameters = [], array $server = [], bool $changeHistory = true) : Crawler {
    $content = json_encode($parameters);
    $this->setServerParameter('CONTENT_TYPE', 'application/json');
    $this->setServerParameter('HTTP_ACCEPT', 'application/json');
    try {
        return $this->request($method, $uri, [], [], $server, $content, $changeHistory);
    } finally {
        unset($this->server['CONTENT_TYPE']);
        unset($this->server['HTTP_ACCEPT']);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal