How do I pass parameters as JSON format to the HTTP client request? How can I pass parameters to the http client get request in json format:

$clientFactory = \Drupal::service('http_client_factory');
$client = $clientFactory-&gt;fromOptions(['verify' =&gt; FALSE]);

$params = '{"data1":"",
"data2":"mydata"
"data3":"mydata",
"data3":"mydata",
"data5":"mydata"}';

$url = 'https://myendpointurl';
try {
  $response = $client-&gt;get($url, array(
      'headers' =&gt; array('Accept' =&gt; 'text/plain'),
    )
  );
  $data = json_decode($response-&gt;getBody());
}
catch (RequestException $e) {
  watchdog_exception('my_module', $e-&gt;getMessage());
}


Where I need to put $params variable in my code?
You can add it to the request like so:

use Drupal\Component\Serialization\Json;
...
$response = $client-&gt;get($url, [
    'headers' =&gt; ['Accept' =&gt; 'text/plain'],
    'json' =&gt; Json::decode($params),
]);