When I want to set the value ‘disabled’ to the current date via API, I get the following error message: “body”:{“disabled”:{“dateTime”: “The disabled date should be a valid date.”}.
I use PHP to generate the date:
$currentDateTime = date(‘Y-m-d\TH:i:sP’);
My PHP code:
$currentDateTime = date(‘Y-m-d\TH:i:sP’);
$data = [
‘active’ => false,
‘disabled’ => $currentDateTime,
‘changed’ => $currentDateTime
];
// Step 2: PUT call with the CSRF token cookie
$ch = curl_init($config[‘server_url’] . ‘/users/.json?api-version=v2’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_COOKIE, $gpgAuth->getCookie());
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-CSRF-Token: ’ . $csrfToken,
‘Accept: application/json’,
‘Content-Type: application/json’,
'Cookie: ’ . $sessionCookie
));
$response = curl_exec($ch);
curl_close($ch);