uploadFile

uploadFile

Purpose

You can use this method to attach files to records.

Request URL

For OAuth Authentication

Header Name
Value
Authorization
Zoho-oauthtoken {access_token}

Scopes

Scope=ZohoRecruit.modules.all
(or)
Scope=ZohoRecruit.modules.{scope_name}.{operation_type}
Possible Scope Names (Case Sensitive)
Operation Types
referral, campaign, assessment, vendor, offer, attachment, 
forecast, note, call, event, task, candidate, jobopening, client, department, interview, contact & custom (for all Custom Modules)
ALL - Full access to the record
READ - Get records from the module

For Authtoken Authentication

Parameter
Data Type
Description
authtoken*
String
Encrypted alphanumeric string to authenticate your Zoho credentials. 
scope*
String
Specify the value as recruitapi

Request Parameters

Parameter
Data Type
Description
id*
String
Specify the unique ID of the record to which the file has to be attached.
content*
FileInputStream
Pass the File Input Stream of the file.
type*
String
Specify the attachment type (E.g. Resume or Others).
version*
Integer
Use version=2: This will fetch responses based on the latest API implementation.
Note:
  1. Parameters marked with * are mandatory.
  2. The total file size should not exceed 20 MB.
  3. Your program can request only 15 uploadFile calls per 5 min. If API User requests more than 15 calls, system will block the API access for 15 min. 
  4. If the size exceeds 20 MB, you will receive the following error message: "File size should not exceed 20 MB".
  5. The attached file will be available under the Attachments section in the Record Details Page.
  6. Files can be attached to records in all modules except Reports, Dashboards, and Forecasts.

Java Code to Upload a file for a record

You can run this program in your Java Environment to upload a file to a record.
In the program, you need to specify values for the following:
  1. Your Auth Token
  2. The ID of the Record
  3. The uploadFile Request URL in the format mentioned above
  4. The File Path i.e the location of the File
Code Snippet:
import java.io.*;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.PartSource;
import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
 
public class UploadFile 
{
      public static void main(String a[])
      {
            try
            {
                  String auth_token = "USER AUTH TOKEN"; 
                  String auth_scope = "recruitapi";
                  String targetURL = "https://recruit.zoho.com/recruit/private/xml/Candidates/uploadFile";
                  String recordId = "RECORD ID";
                  String file = "FILE NAME
                  File f = new File(file);
                  FileInputStream fis = new FileInputStream(f);
                  ByteArrayOutputStream bos = new ByteArrayOutputStream();
                  int c;
                  while ((c = fis.read()) != -1)
                  {
                        bos.write(c);
                  }
                  byte[] fbArray = bos.toByteArray();
                  targetURL = targetURL + "?authtoken="+ auth_token +"&scope="+ auth_scope+"&version=2";
                  PartSource ps = new ByteArrayPartSource(file,fbArray);
                  PostMethod post =new PostMethod(targetURL);
                  Part[] fields = { new FilePart("content",ps), new StringPart("id", recordId), new StringPart("type", "Cover Letter") };
                  post.setRequestEntity(new MultipartRequestEntity(fields,post.getParams()));
                  HttpClient httpclient = new HttpClient();
                  httpclient.executeMethod(post);
                  String postResp = post.getResponseBodyAsString();
                  System.out.println("postResp===========> : "+postResp);
            }
            catch(Exception e)
            {
                  e.printStackTrace();
            }
      }
}

PHP Code to Upload a file for a record (for PHP versions 5.5 or higher)

Code Snippet:
<?php
$recordId="RECORD ID";
$ch=curl_init();
$cFile = new CURLFile('/home/path/to/my/file.pdf','application/pdf',")
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_VERBOSE,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_URL,"
https://recruit.zoho.com/recruit/private/xml/Candidates/uploadFile?authtoken=<Your Authtoken>&scope=recruitapi&version=2&type=<attachment type>");
curl_setopt($ch,CURLOPT_POST,true);
$post=array("id"=>$recordId,"content"=>$cFile);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post);
$response=curl_exec($ch);
echo $response;
?>

Sample Response

<?xml version="1.0" encoding="UTF-8" ?>
<response uri="/recruit/private/xml/Candidates/uploadFile">
      <result>
            <message>File has been attached successfully</message>
            <recorddetail>
                  <FL val="Id">335751000000578001</FL>
                  <FL val="Created Time">2012-06-20 14:57:34</FL>
                  <FL val="Modified Time">2012-06-20 14:57:34</FL>
                  <FL val="Created By"><![CDATA[krrish]]></FL>
                  <FL val="Modified By"><![CDATA[krrish]]></FL>
            </recorddetail>
      </result>
</response>

Data Storage Limits

Default storage limits for the organization are:
  1. Free Edition - 256 MB for the Org.
  2. Standard Edition - 1GB
  3. Professional Edition - 2GB
  4. Enterprise Edition - 3GB
Extra file storage: USD 3/Month/GB
For the existing users, the revised pricing will be applicable from the next billing cycle.

    • Related Articles

    • Is it possible to upload and associate an attachment with a record through Zoho CRM API?

      Yes. It is possible to associate an attachment with a record through the Zoho CRM API, using the uploadFile method to attach files to records. See Also: uploadFile Method
    • API Methods

      Method Name Purpose getRecords To retrieve all users data specified in the API request getRecordById To retrieve individual records by record ID addRecords To insert records into the required Zoho Recruit module updateRecords To update or modify the ...
    • Class Hierarchy - Node JS SDK

      All Zoho CRM entities are modelled as modules having classes, methods and instance variables applicable to that particular entity. ZCRMRestClient is the base class of the Python SDK. ZCRMRestClient has methods to get instances of various other Zoho ...
    • uploadPhoto

      Purpose You can use this method to upload photos for Candidates or Contacts. Request URL XML Format: For Candidates: https://recruit.zoho.com/recruit/private/xml/Candidates/uploadPhoto?authtoken=AuthToken&scope=recruitapi&id=RecordId&content=File ...
    • Sample Codes - Node JS SDK

      All of Zoho CRM's APIs can be used through the Node JS SDK, to enable your custom application to perform data sync to the best degree. Here are the sample codes for all the API methods available in our SDK. Organization & User Operations These ...