Issue with API File Upload

Issue with API File Upload

Hi,

I'm having an issue with the File Upload request using the API.

I'm able to create a contact and link that to a potential (Loan Application), but when uploading the file, it simply returns 'True' rather than the expected reponse in the API Documentation:

https://www.zoho.com/crm/developer/docs/api/upload-attachment.html

The true response implies the request was successful, however it is not linking to the Loan Application.

The PHP code is shown below:

  1. $loan_application_ID = $data["data"][0]['details']["id"];
    $proof_of_income = stripslashes($entry['11']);

    $data = json_decode($token, true);

    $apiUrl = "https://www.zohoapis.eu/crm/v2/Potentials/" . $loan_application_ID . "/Attachments";

    $upload_path = GFFormsModel::get_upload_path( $entry[ 'form_id' ] );

    $file_poi = basename($proof_of_income);

    $fp = fopen($upload_path . "/" . date("Y") . "/" . date("m") . "/" . $file_poi, "w"); // Destination location

    // *strlen must be called after defining the variable. So moved headers down to $fields*

    $headers = array(
    'Content-Type: multipart/form-data',
    sprintf('Authorization: Zoho-oauthtoken %s', $data["access_token"])
    );

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_URL, $apiUrl);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    //curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    curl_setopt($ch, CURLOPT_FILE, $fp);

    $output = curl_exec($ch);

    $data = json_decode($output, true);

Any help would be appreciated!