When attempting to download a file using the Zoho CRM REST API the json is returning NULL.
I first pull a list of attachement information using CURL:
curl_setopt_array($curl, array(
CURLOPT_URL =>"https://www.zohoapis.com/crm/v2/Potentials/################/Attachments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Zoho-oauthtoken $refresh_token",
"Content-Type: application/json"
),
));
This returns information as expected:
{
"data": [
{
"Owner": {
"name": "So Broken",
"id": "###6044000036######",
"email": "why@zoho.com"
},
"Modified_Time": "2021-03-30T17:43:41-07:00",
"File_Name": "Broken.pdf",
"Created_Time": "2021-03-30T17:43:41-07:00",
"Size": "58949",
"Parent_Id": {
"name": "Me Broken",
"id": "###6044000041######"
},
"$editable": true,
"$file_id": "ays10bfd51###d1894c63a4d59db45#######",
"$type": "Attachment",
"$se_module": "Deals",
"Modified_By": {
"name": "Me Broken",
"id": "###604400003######",
"email": "why@zoho.com"
},
"$state": "save",
"id": "###6044000040######",
"Created_By": {
"name": "Me Broken",
"id": "###6044000036######",
"email": "why@zoho.com"
},
"$link_url": null
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
I then grab the ID in yellow for use in the download:
curl_setopt_array($curl, array(
CURLOPT_URL =>"https://www.zohoapis.com/crm/v2/Potentials/################/Attachments/###6044000036######",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Zoho-oauthtoken $refresh_token",
"Content-Type: application/json"
),
));