I want to send POST request to https using \Drupal::httpClient(). But ended up with error like
GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: self signed certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Below is my code.
$post_fields['name'] = 'aa';
$fields_string = json_encode($post_fields);
$response = \Drupal::httpClient()
->post("https://localhost/example/api/user-update?_format=json", [
'auth' => ['admin', 'admin'],
'body' => $fields_string,
'http_errors' => FALSE,
'headers' => [
'Content-Type' => 'application/json',
],
]);
dsm($response->getBody()->getContents());
How to send POST request with \Drupal::httpClient().