Attendance Bulk Import API

This API is used to bulk import the check-in and check-out details of the employees. The system will mark the attendance entry/exit for all of the employees, in a bulk, once their ID cards are swiped through the attendance terminals.You can integrate this API with the attendance terminals in your organization to map the user ID of employees.

Request URL

https://people.zoho.com/people/api/attendance/bulkImport?data=<JSONArray>;

Header:

Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf

Request parameter

data

[{"empId":"1","checkIn":"2014-11-07 09:01:00"}, {"empId":"1","checkOut":"2014-11-07 18:02:00"},

{"empId":"2","checkIn":"2014-11-07 09:01:00"}, {"empId":"2","checkOut":"2014-11-07 18:02:00"}]

dateFormatyyyy-MM-dd HH:mm:ss

Note: Attendance Bulk Import API can also be done using Attendance Device Integration.

 Threshold Limit:  10 requests | Lock period: 5 minutes

Threshold Limit - Number of API calls allowed within a minute.
Lock Period - Wait time before consecutive API requests.

Prerequisite

JDK 1.6 commons-codec-1.3.jar, commons-httpclient-3.0.1.jar and commons-logging-11.jar files are available in the CLASSPATH

Header

CopiedAuthorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf

Code Snippet

Copiedimport java.io.*;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.json.JSONArray;
import org.json.JSONObject;
public class JavaCode { public static void main(String a[]) { try { JSONArray array = new JSONArray();
JSONObject val = new JSONObject();
val.put("empId", "1");
val.put("checkIn", "2014-11-07 09:01:00");
array.put(val);
val = new JSONObject();
val.put("empId", "1");
val.put("checkOut", "2014-11-07 09:01:00");
array.put(val);
String targetURL = "https://people.zoho.com/people/api/attendance/bulkImport";
String dateTimeFormat = "yyyy-MM-dd HH:mm:ss";
PostMethod post = new PostMethod(targetURL);
post.setParameter("dateFormat", dateTimeFormat);
post.setParameter("data", array.toString());
HttpClient httpclient = new HttpClient();
PrintWriter myout = null; /*-------------------------------------- Execute the http request--------------------------------*/ try { long t1 = System.currentTimeMillis();
int result = httpclient.executeMethod(post);
System.out.println("HTTP Response status code: " + result);
System.out.println(">> Time taken " + (System.currentTimeMillis() - t1));
/*-------------------------------------- Execute the http request--------------------------------*/ /* ---------------------------writing the response to a file--------------------*/ myout = new PrintWriter(new File("response.xml"));
myout.print(post.getResponseBodyAsString());
/* ---------------------------writing the response to a file--------------------*/ /*-----------------------Get response as a string ----------------*/ String postResp = post.getResponseBodyAsString();
System.out.println("postResp=======>" + postResp);
/* ---------------------Get response as a string ----------------------------*/ if (postResp.equals("Invalid Ticket Id")) { // generate new auth token and call the API } } catch (Exception e) { e.printStackTrace();
} finally { myout.close();
post.releaseConnection();
} } catch (Exception e) { e.printStackTrace();
} } }
Copiedusing System.Web;
using System..Net;
String zohopeopleurl = "https://people.zoho.com/people/api/attendance?";
postContent = postContent + "&dateFormat=dd/MM/yyyy HH:mm:ss&checkIn=02/01/2014 08:00:00&checkOut=02/01/2014 05:00:00&empId=3";
string result = AccessAPI(zohopeopleurl, postContent);
public static string AccessAPI(string url, string postcontent)
{
byte[] bodyBytes = System.Text.Encoding.UTF8.GetBytes(postcontent);
HttpWebRequest request = default(HttpWebRequest);
request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "Post"; //methodtype;//-post or get
request.ContentType = "application/x-www-form-urlencoded";
using (Stream ostream = request.GetRequestStream())
{
ostream.Write(bodyBytes, 0, bodyBytes.Length);
ostream.Flush();
ostream.Close();
}
HttpWebResponse response = default(HttpWebResponse);
response = (HttpWebResponse)request.GetResponse();
StreamReader strrespo = default(StreamReader);
strrespo = new StreamReader(response.GetResponseStream());
string s = null;
s = strrespo.ReadToEnd();
return s;
}
Copied$request_url = 'https://people.zoho.com/people/api/attendance'; $dateFormat = "dd/MM/yyyy HH:mm:ss"; $checkIn = "29/10/2014 09:05:00"; $checkOut = "29/10/2014 17:30:00"; $empID = "1"; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); "&checkIn=" . $checkIn . "&checkOut=" . $checkOut . "&dateFormat=" . $dateFormat . "&empId=" . $empID; curl_setopt($ch, CURLOPT_POSTFIELDS, $request_param); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); $response_info = curl_getinfo($ch); curl_close($ch); $response_body = substr($response, $response_info['header_size']); echo '\nRequest Parm : ' . $request_param; echo "\nResponse HTTP Status Code : "; echo $response_info['http_code']; echo "\nResponse" . $response_body; ?>