Commit da5b1909 authored by Vikas's avatar Vikas

Added api examples

parents
<?xml version="1.0" ?>
<api method="post">
<create module=”Potentials”>
<record>
<field name="potentialname" value="@name"></field>
<field name="amount" value="@amount"></field>
<field name="contact_id" module="Contacts">
<select>
<where>
<field name="email" value="@email"></field>
</where>
</select>
<create>
<record>
<field name="lastname" value="@lastname"></field>
<field name="firstname" value="@firstname"></field>
<field name="email" value="@email"></field>
<field name="contacttype" value="Lead"></field>
</record>
</create>
</field>
</record>
</create>
</api>
<?xml version="1.0" ?>
<api method="post">
<create module=”Contacts”>
<record>
<field name="firstname" value="@firstname"></field>
<field name="lastname" value="@lastname"></field>
<field name="email" value="@email"></field>
</record>
<return>
<field name="id"></field>
</return>
</create>
</api>
<?xml version="1.0" ?>
<api method="post">
<rest method="post">
<url SHEETID="@sheetid" OPTIONS="values/Sheet1!A1:append?valueInputOption=RAW">https://sheets.googleapis.com/v4/spreadsheets/$SHEETID/$OPTIONS</url>
<auth>
<oauth type="vtap" service="Google" module="CUSTOM_MODULE"> </oauth>
</auth>
<parameters raw-post-data="true">
<parameter name='values' value='@row_data' presence="optional"></parameter>
</parameters>
</rest>
</api>
<?xml version="1.0" ?>
<api method="get">
<rest>
<url>https://sheets.googleapis.com/v4/spreadsheets/sheetID</url>
<auth>
<bearer token="@token" />
</auth>
</rest>
</api>
# VTAP
ApiDesignerExamples folder has examples for custom REST API's or invoke other application HTTP end points.
**Note** :
1. For external applications you need to white list them. This can be added from API Designer list view > Settings.
2. Unique names should be given for each api's so they can be identifed easily.
**VADL** : Defining API's are dependent on VADL (Vtiger Api Definition Language). This language is loosely based on xml format.
VADL provides following options to create api's.
1. api - all the api's are defined within this node. It has attribute method which decides the http type of api request.
Example :
<?xml version="1.0" ?>
<api method="get">
//API definition
</api>
2. select - used to select vtiger records.
Example :
* Select module records with where condition
<?xml version="1.0" ?>
<api method="get">
<select module="Contacts">
<record>
<field name="firstname"> </field>
<field name="lastname"> </field>
</record>
<where>
<field name="email" value="[email protected]"> </field>
</where>
</select>
</api>
* Select module with value binding
<?xml version="1.0" ?>
<api method="get">
<select module="Contacts">
<record>
<field name="firstname"> </field>
<field name="lastname"> </field>
</record>
<where>
<field name="email" value="@email_address"> </field>
</where>
</select>
</api>
3. create - create vtiger record by passing request parameters and respond back with response defined by fields.
Example :
* Create Contacts with value binding
<?xml version="1.0" ?>
<create module=”Contacts”>
<record>
<field name="firstname" value="@firstname"></field>
<field name="lastname" value="@lastname"></field>
<field name="email" value="@email"></field>
</record>
<return>
<field name="id"></field>
<field name="firstname"></field>
<field name="lastname"></field>
<field name="email"></field>
<field name="assigned_user_id"></field>
</return>
</create>
* Create Potential with reference field
<?xml version="1.0" ?>
<api method="post">
<create module=”Potentials”>
<record>
<field name="potentialname" value="@name"></field>
<field name="amount" value="@amount"></field>
<field name="contact_id" module="Contacts">
<select>
<where>
<field name="email" value="@email"></field>
</where>
</select>
<create>
<record>
<field name="lastname" value="@lastname"></field>
<field name="firstname" value="@firstname"></field>
<field name="email" value="@email"></field>
<field name="contacttype" value="Lead"></field>
</record>
</create>
</field>
</record>
</create>
</api>
4. update - it will update existing vtiger record.
Example :
* Update contacts using email address field.
<?xml version="1.0" ?>
<api method="put">
<update module="Contacts">
<record>
<field name="email" value="@email"></field>
</record>
<return>
<field name="id"></field>
</return>
<where>
<field name="email" condition="eq" value="@old_email"></field>
</where>
</update>
</api>
5. upsert - update if record found else create new record.
Example :
* Search a contact by id, if found update else create new contact.
<?xml version="1.0" ?>
<api method="post" module=”Contacts”>
<upsert>
<where>
<field name="id" condition="eq" value="@CRMID"></field>
</where>
<update>
<record>
<field name="email" value="@email" presence="optional" ></field>
</record>
</update>
<create>
<record>
<field name="firstname" value="@firstname" presence="optional" ></field>
<field name="lastname" value="@lastname" presence="optional" ></field>
<field name="email" value="@email" presence="optional" ></field>
</record>
</create>
<return>
<field name="id"></field>
</return>
</upsert>
</api>
6. delete - this will delete vtiger record
Example :
* Delete records
<?xml version="1.0" ?>
<api method="delete">
<delete module="@module">
<where>
<field name="id" condition="eq" value="@CRMID"></field>
</where>
</delete>
</api>
<?xml version="1.0" ?>
<api method="get">
<select module="Contacts">
<record>
<field name="firstname"> </field>
<field name="lastname"> </field>
</record>
<where>
<field name="email" value="[email protected]"> </field>
</where>
</select>
</api>
<?xml version="1.0" ?>
<api method="get">
<select module="Contacts">
<record>
<field name="firstname"> </field>
<field name="lastname"> </field>
</record>
<where>
<field name="email" value="@email_address"> </field>
</where>
</select>
</api>
<?xml version="1.0"?>
<api method="get">
<rest method="get">
<url>https://slack.com/api/conversations.list</url>
<auth>
<oauth type="vtap" service="slack" module="Contacts"></oauth>
</auth>
</rest>
</api>
<?xml version="1.0"?>
<api method="get">
<rest method="get">
<url>https://slack.com/api/users.list</url>
<auth>
<oauth type="vtap" service="slack" module="Contacts"></oauth>
</auth>
</rest>
</api>
<?xml version="1.0"?>
<api method="post">
<rest method="post">
<url>https://slack.com/api/chat.postMessage</url>
<auth>
<oauth type="vtap" service="slack" module="Contacts"></oauth>
</auth>
<parameters>
<parameter name='channel' value='@channel'></parameter>
<parameter name='blocks' value='@blocks'></parameter>
<parameter name='text' value='@text'></parameter>
</parameters>
</rest>
</api>
<?xml version="1.0" ?>
<api method="put">
<update module="Contacts">
<record>
<field name="email" value="@new_email"></field>
</record>
<return>
<field name="id"></field>
</return>
<where>
<field name="email" condition="eq" value="@old_email"></field>
</where>
</update>
</api>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment