How can I pass parameters to the http client get request in json format:
$clientFactory = \Drupal::service('http_client_factory');
$client = $clientFactory->fromOptions(['verify' => FALSE]);
$params = '{"data1":"",
"data2":"mydata"
"data3":"mydata",
"data3":"mydata",
"data5":"mydata"}';
$url = 'https://myendpointurl';
try {
$response = $client->get($url, array(
'headers' => array('Accept' => 'text/plain'),
)
);
$data = json_decode($response->getBody());
}
catch (RequestException $e) {
watchdog_exception('my_module', $e->getMessage());
}
Where I need to put $params
variable in my code?