File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,20 @@ The value returned by the ``request()`` method is an instance of the
80
80
:doc: `DomCrawler component </components/dom_crawler >`, which allows accessing
81
81
and traversing HTML elements programmatically.
82
82
83
+ The :method: `Symfony\\ Component\\ BrowserKit\\ AbstractBrowser::jsonRequest ` method,
84
+ which defines the same arguments as the ``request() `` method, is a shortcut to
85
+ convert the request parameters into a JSON string and set the needed HTTP headers::
86
+
87
+ use Acme\Client;
88
+
89
+ $client = new Client();
90
+ // this encodes parameters as JSON and sets the required CONTENT_TYPE and HTTP_ACCEPT headers
91
+ $crawler = $client->jsonRequest('GET', '/', ['some_parameter' => 'some_value']);
92
+
93
+ .. versionadded :: 5.3
94
+
95
+ The ``jsonRequest() `` method was introduced in Symfony 5.3.
96
+
83
97
The :method: `Symfony\\ Component\\ BrowserKit\\ AbstractBrowser::xmlHttpRequest ` method,
84
98
which defines the same arguments as the ``request() `` method, is a shortcut to
85
99
make AJAX requests::
You can’t perform that action at this time.
0 commit comments