PHP Curl Bad Request JSON — the problem is the message — how to format?

there is a date array that is passed to send using curl in fukcnig

$arData = [
 "NAME" => 'the title of the conference',
 "CODE" => "",
 "START" => '18.04.19 11:11:10',
];
telegramNotificationSend($id, $typeNotification, $arData);

in the send function there is code form the message

$textNotification = "Conference" . $arData["NAME"] . " will soon begin. Start time in " . $arData["START"];

Executing curl in response says Bad Request

If you send just a text string, no substitution of the information from the array arData, then everything sends correctly

$textNotification = $dateStart . "The conference will begin shortly. Start time in ";

code send

$data_string = json_encode ($data, JSON_UNESCAPED_UNICODE);
 $curl = curl_init(TELEGRAM_BOT_URL);
 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
 curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
 // Take in an array. (false - object)
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($curl, CURLOPT_HTTPHEADER, array(
 'key:' . TELEGRAM_BOT_KEY,
 'Content-Type: application/json',
 'Content-Length:' . strlen($data_string))
);
 $result = curl_exec($curl);
 curl_close($curl);

Even if just to equate $textNotification = $arData["NAME"], it will also be an error Bad Request.

What could be the problem? Hidden details and symbols in the transmission? But I'm just one line compared to another, where they can appear?
April 19th 20 at 12:27
1 answer
April 19th 20 at 12:29
Solution
The problem is solved:
1) encode json without JSON_UNESCAPED_UNICODE
2) added to the header charset=utf-8
$data_string = json_encode ($data);
'Content-Type: application/json; charset=utf-8',

Find more questions by tags PHP