Migrating From Version 1 API to Version 2 "Facing Issues"

Migrating From Version 1 API to Version 2 "Facing Issues"

<?php
   $apiUrl = "https://www.zohoapis.com/crm/v2/Leads/";

$fields = json_encode(array("data" => array(["City" => "Egham"])));

$headers = array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($fields),
    'Authorization: Zoho-oauthtoken 4869c41171910edf553c07461c59a059',

);


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$response = curl_exec($ch);
curl_close($ch);
return $response;
?>
i dont know why some times it gives White Screen Error Some times 500 Error.