Zoho Recruit | uploadPhoto Method

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 Input Stream&version=2

For Contacts:
https://recruit.zoho.com/recruit/private/xml/Contacts/uploadPhoto?authtoken=AuthToken&scope=recruitapi&id=RecordId&content=File Input Stream&version=2

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.
content*
FileInputStream
Pass the FileInputStream of the photo.
version*
Integer
Use version=2: This will fetch responses based on the latest API implementation.
Note:
  1. Parameters marked with * are mandatory.
  2. 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 for a Candidate or Contact

You can run this program in your Java Environment to upload the photo for a candidate or contact.
In the program, you need to specify values for the following:
  1. Your Auth Token
  2. The ID of the Record
  3. The uploadPhoto Request URL in the format mentioned above
  4. The File Path i.e. the location of the photo
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/uploadPhoto ";
                  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), };
                  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();
            }
      }
}
Sample Response:
<?xml version="1.0" encoding="UTF-8" ?>
<response uri="/recruit/private/xml/Candidates/uploadPhoto">
<status>
<code>200</code>
</status>
<success>
<code>4800</code>
<message>Photo uploaded successfully</message>
</success>
</response>

PHP Code to Upload Photo for a Candidate or Contact (for PHP versions 5.5 or higher)

Code Snippet:
<?php
$recordId="RECORD ID";
$ch=curl_init();
$cFile = new CURLFile('/home/path/to/my/photo.png','image/png',")
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/uploadPhoto?authtoken= <Your Authtoken>&scope=recruitapi&version=2");
curl_setopt($ch,CURLOPT_POST,true);
$post=array("id"=>$recordId,"content"=>$cFile);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post);
$response=curl_exec($ch);
echo $response;
?>

    Zoho CRM Training Programs

    Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

    Zoho CRM Training
      Redefine the way you work
      with Zoho Workplace

        Zoho DataPrep Personalized Demo

        If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

        Zoho CRM Training

          Create, share, and deliver

          beautiful slides from anywhere.

          Get Started Now


            Zoho Sign now offers specialized one-on-one training for both administrators and developers.

            BOOK A SESSION








                                You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                    Manage your brands on social media

                                      Zoho Desk Resources

                                      • Desk Community Learning Series


                                      • Digest


                                      • Functions


                                      • Meetups


                                      • Kbase


                                      • Resources


                                      • Glossary


                                      • Desk Marketplace


                                      • MVP Corner


                                      • Word of the Day


                                        Zoho Marketing Automation

                                          Zoho Sheet Resources

                                           

                                              Zoho Forms Resources


                                                Secure your business
                                                communication with Zoho Mail


                                                Mail on the move with
                                                Zoho Mail mobile application

                                                  Stay on top of your schedule
                                                  at all times


                                                  Carry your calendar with you
                                                  Anytime, anywhere




                                                        Zoho Sign Resources

                                                          Sign, Paperless!

                                                          Sign and send business documents on the go!

                                                          Get Started Now




                                                                  Zoho TeamInbox Resources



                                                                          Zoho DataPrep Resources



                                                                            Zoho DataPrep Demo

                                                                            Get a personalized demo or POC

                                                                            REGISTER NOW


                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now







                                                                                            You are currently viewing the help articles of Sprints 1.0. If you are a user of 2.0, please refer here.

                                                                                            You are currently viewing the help articles of Sprints 2.0. If you are a user of 1.0, please refer here.



                                                                                                  • Related Articles

                                                                                                  • 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 ...
                                                                                                    Wherever you are is as good as
                                                                                                    your workplace

                                                                                                      Resources

                                                                                                      Videos

                                                                                                      Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                      eBooks

                                                                                                      Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                      Webinars

                                                                                                      Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                      CRM Tips

                                                                                                      Make the most of Zoho CRM with these useful tips.



                                                                                                        Zoho Show Resources