CRM Help

uploadPhoto Method


You can use this method to upload photos to Leads or Contacts.

Request URL

XML Format:

For Leads: Token&scope=crmapi&id=Record Id&content=File Input Stream

For Contacts: Token&scope=crmapi&id=Record Id&content=File Input Stream

Request Parameters

Parameter Data Type Description
authtoken* String Encrypted alphanumeric string to authenticate your Zoho credentials.
scope* String Specify the value as crmapi
id* String Specify unique ID of the record
content* FileInputStream Pass the FileInputStream of the photo

* - Mandatory parameter


  • The size of each photo should not exceed 2 MB. If the size exceeds 2 MB, you will receive the following error message: "File size should not exceed 2 MB".

Java Code to Upload Photo to a Lead or Contact

You can run this program in your Java Environment to upload a photo to a lead or a contact.

In the program, you need to specify values for the following:

  • Your Auth Token
  • The ID of the Record
  • The uploadPhoto Request URL in the format mentioned above
  • The File Path i.e the location of the photo


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 UploadPhoto 
      public static void main(String args[])
                  String auth_token = "USER AUTH TOKEN";
                  String auth_scope = "crmapi";
                  String targetURL = "";
                  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 = != -1)
                  byte[] fbArray = bos.toByteArray();
                        targetURL = targetURL + "?authtoken="+ auth_token +"&ampscope="+ auth_scope;
                  PartSource ps = new ByteArrayPartSource(file,fbArray);
                  PostMethod post =new PostMethod(targetURL);
                  Part[] fields = { new FilePart("content",ps), new StringPart("id", recordId), };
                  post.setRequestEntity(new MultipartRequestEntity(fields,post.getParams()));
                  HttpClient httpclient = new HttpClient();
                  String postResp = post.getResponseBodyAsString();
                  System.out.println("postResp===========&gt : "+postResp);
            catch(Exception e)


Sample Response

<?xml version="1.0" encoding="UTF-8" ?>
<response uri="/crm/private/xml/Leads/uploadPhoto">
<message>Photo uploaded succuessfully</message>

PHP Code to Upload Photo to a Lead or Contact

curl_setopt($ch,CURLOPT_URL,"<Your Authtoken>&scope=crmapi");
echo $response;


Spread the Word

© 2016, ZOHO Corp. | Support: +1 888-900-9646 | Sales: +1 877 834 4428,