Professional Documents
Culture Documents
Create Lead A Pi
Create Lead A Pi
Document Information
Created by:
Ben Lazarev
Creation date:
13-Nov-2013
File name:
Document type:
API documentation
Confidentiality:
Confidential
Document Status
Version
Status
Set by
Date
1.0.0
1st
draft
Ben Lazarev
13-Nov-2013
1.01
Update fields
Gilad tabachnik
2-Apr-2015
Contents
Introduction
Overview
Scope & Audience
Terms, Acronyms & Abbreviations
Applicable Documents
General
Response Object
Error Object
General Flow
Authentication
Get Challenge
GetChallengeResult
Login
Create New Lead Entity
Create Lead example
Parameters List
1.
Introduction
1.1. Overview
Currently Lead can be created in two ways, using Webform and from the CRM list view . Panda will
provide API to create Lead from external server.
REST
- API is REST based, so all the communication b/w client and server can happen over
HTTP as GET or POST requests.
JSON
- JSON is used to encode response and request.
Requests And Responses
- Your client application prepares and submits a service request to
the API, the API processes the request and returns a response, and the client application
handles the response.
2. General
2.1. Response Object
All responses will have the following format. If the request is processed successfully:
<code>Response{
success:Boolean=true
result:Object//TheOperationResultobject
}
</code>
3. General Flow
In order to create a new CRM Lead entity, there are several preconditions to be met and several steps
to perform:
3.1. Authentication
The API does not use the password to log in. Instead, Vtiger provides a unique access key for each
user. To get the user key for a user, login to CRM and navigate to My Preferences pane of that user
using which you logged in . You will find an Access Key field with value to be used.
Login starts a client session with server, authenticates the user and returns a sessionId which will be
used for all the subsequent communication with the server.
Logging in is a two-step process, In the first step client obtains the challenge token from the server,
which is used along with the user's access key to log in.
Now that we have the challenge token we can go ahead with the login. The access key field in the
login operation is the md5 checksum of the concatenation of the challenge token and the users own
access key.
3.1.2. Login
Logintotheserverusingthechallengetokenobtainedingetchallengeoperation
Example:
http://123.123.21.54/webservice.php?operation=login&username=panda&accessKey=KntFVnh7FvXy
aloP
ForaccessKeycreateamd5stringafterconcatenatinguseraccesskeyfrommypreferencepageandthe
challengetokenobtainedfromgetchallengeresult.
$generatedKey = md5($challengeToken.$userAccessKey);
Login example:
<code>//e.g.
//accesskeyoftheuser,foundonmypreferencespage.
$userAccessKey=
QsRvAuzZYAt6yp1h
//createmd5stringconcatenatinguseraccesskeyfrommypreferencepage
//andthechallengetokenobtainedfromgetchallengeresult.
$generatedKey=md5($challengeToken.$userAccessKey)
//loginrequestmustbePOSTrequest.
$httpc>post("$endpointUrl",
array('operation'=>'login','username'=>$userName,
'accessKey'=>$generatedKey),true)
$response=$httpc>currentResponse()
//decodethejsonencoderesponsefromtheserver.
$jsonResponse=Zend_JSON::decode($response['body'])
//operationwassuccessfulgetthetokenfromthereponse.
if($jsonResponse['success']==false)
//handlethefailurecase.
die('loginfailed:'.$jsonResponse['error']['errorMsg'])
//loginsuccessfulextractsessionIdanduserIdfromLoginResulttoitcanused
forfurthercalls.
$sessionId=$jsonResponse['result']['sessionName']
$userId=$jsonResponse['result']['userId']
</code>
Login Result
Anobjectrepresentingtheresponseresultofaloginoperation,
<code>LoginResult{
sessionId:String//UniqueIdentifierforthesession
userId:String//Thevtigeridfortheloggedinuser
version:String//Theversionofthewebservicesapi
vtigerVersion:String//Theversionofthevtigercrm.
}
</code>
);
$jsonResponse = json_decode($response,true);
if($jsonResponse['success']==false)
die('login failed:'.$jsonResponse['success']['error']['message']);
$sessionId = $jsonResponse['result']['sessionName'];
$userId = $jsonResponse['result']['userId'];
$sessionId = $jsonResponse['result']['sessionName'];
$element = array(
email=>test@tes.oom
,assigned_user_id=>19x1
,lastname=>mosh
,firstname=>eli
,mobile=>0568452654
,leadsource=>--None--
);
$objectJson = json_encode($element);
$params = array("sessionName"=>$sessionId
, "operation"=>'create'
, "element"=>$objectJson
, "elementType"=>Leads
);
$response = curl_post($endpointUrl,$params);
$arr_response = json_decode($response,true);
assigned_user_id
lastname
firstname
Optional fields :
phone
phone number
mobile
mobile number
fax
fax number
leadstatus
Lead Status
leadsource
source name
lane
Street
code
Postal Code
city
City
country
Country
state
State
pobox
Po Box
description
Description
affiliate
Affiliate