Problem with PHP Script accessing Zoho CRM API with curl

Problem with PHP Script accessing Zoho CRM API with curl

 I'm trying to access the Zoho API via Curl and PHP using the code below. It's able to get records, but when trying to insert some sample XML it's throwing a 4500 error code.

(I'm generating the tickets ok, which is being inserted into the URL below)

Where am i going wrong? I'm going bonkers - i've been banging my head against this brick wall for 2 evenings now!!

   
  1. $api_key = 'hiddenfromview';
    $zoho_url = 'http://crm.zoho.com/crm/private/xml/';

    $xml ='<?xml version="1.0" encoding="UTF-8"?><Leads><row no="1"><FL val="Lead Source">paris hotels</FL><FL val="First Name">contacto 1</FL><FL val="Last Name">apellido</FL><FL val="Email">testing@testing.com</FL><FL val="Phone">1234567890</FL><FL val="Home Phone">0987654321</FL><FL val="Other Phone">1212211212</FL><FL val="Fax">02927272626</FL><FL val="Mobile">292827622</FL></row></Leads>';

    // Create headers
    $header[] = "Host: ".$zoho_url.'Leads/insertRecords';
    $header[] = "Content-type: text/xml";
    $header[] = "Content-length: ".strlen($xml) . "\r\n";
    $header[] = $xml;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $zoho_url.'Leads/insertRecords?apikey='.$api_key.'&ticket='.$ticket);
    curl_setopt($ch, CURLOPT_HEADER, $header);

    //make the request
    $result = curl_exec($ch);