# Webservice REST

These Web services allow you to do HTTP requests to the specified endpoints (VTE\_URL/restapi/v1/vtews/METHOD\_NAME).

The requests need POST method, basic authentication (you must set ‘Authentication basic’ into the header which is calculated through a function based on username\* and password\*) and their relative parameters.  
Each one method will give a JSON response with a status and the data or in case of error an error code and its relative message.

**Notes:**  
• The “id” parameter is always specified as ‘moduleid\* x recordid’ (ex: 2x313)   
 \*: You can get the the moduleid from webservice ‘describe’ method (idPrefix)

**Headers:**   
• Authorization: Basic base64\_encode("username\*:password\*")  
• Content-Type : application/json  
  
username\* (VTE) password\* (User preferences’ Webservice Access Key)

Authorization Example:  
‘Basic ZmVkZXJpY28ucGVybGluOjB5cm5MRjNhS2RhMDZ2c3E=‘

  
**Requirements for Apache2:** • Activate apache rewrite module  
• Set AllowOverride All into the virtualhost file to the vte path folder.   
Example:

```
<Directory /var/www/html/VTE_FOLDER>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
```

**Requirements for Nginx + PHP FPM** As Nginx does not handle htaccess file, some special rewrites are needed in order to handle WS requests.  
Below an example of nginx conf file:

```
server {
	listen 80;

	root /var/www/vtenext/;
	
	autoindex off;
	
	index index.php index.html index.htm;

	# Make site accessible from http://localhost/
	
	server_name localhost;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to index.html
		try_files $uri $uri/ index.html;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	location ~ /\.ht {
		deny all;
	}
	
	# special folder handling, since .htaccess files are not supported
	
	# REST API
	
	location /restapi/v1 {
		rewrite ^(.+)/vtews/(.*)$ /restapi/v1/index.php/vtews/$2;
	}
    
    # PORTAL

	location ~ /portal/v2/(?!public) {
		rewrite ^/portal/v2/(.*)$ /portal/v2/public/$1;
	}
	
	# STORAGE
	
	location /storage {
		deny all;
		
		location /storage/uploads_emails_ {
			allow all;
		}
		
		location /storage/images_uploaded/ {
			allow all;
		}
		
		location ~* /storage/logo/.+\.(jpg|jpeg|png|gif)$ {
			allow all;
		}
		
		rewrite ^/storage/(.*)$ /getStorage.php?file=$1;
	}
	
	# PROTECTED FOLDERS
	
	location /logs {
		deny all;
	}
	
	location /plugins/dataimporter {
		deny all;
	}
	
	location /cache/sys {
		deny all;
	}
	
	location /cache/pdfmaker {
		deny all;
	}
	
	location /cache/import {
		deny all;
	}
	
	location /cache/session {
		deny all;
	}
	
	location /cache/pdf {
		deny all;
	}
	
	location /dataimport {
		deny all;
	}
	
	location /modules/VteSync/VteSyncLib/storage {
		deny all;
	}
	
	location /modules/Messages/src/attachment_tnef/plugins/attachment_tnef/class/ {
		deny all;
	}
	
	# SMARTOPTIMIZER
	
	# disabled by default, enable it if needed
	#location ~* \.(gif|jpe?g|png|swf|css|js|html?|xml|txt|ico)$ {
	#	rewrite ^(.*)$ /smartoptimizer/?$1;
	#}
    
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	location ~ [^/]\.php(/|$) {
		include snippets/fastcgi-php.conf;
		
		# With php cgi alone:
		#fastcgi_pass 127.0.0.1:9000;
		
		# With php fpm:
		fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	}
}

```

**Web Service Methods:**

<div id="bkmrk-name-description-par"><table style="width: 100%;"><colgroup> <col style="width: 138px;"></col> <col style="width: 162px;"></col> <col style="width: 143px;"></col> <col style="width: 201px;"></col> </colgroup><tbody><tr><td style="width: 24.1975%;">**Name**</td><td style="width: 22.4691%;">**Description**</td><td style="width: 22.0988%;">**Parameters**</td><td style="width: 31.1111%;">**Response**</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #e0efd4; background: #e0efd4;">**create**</td><td style="width: 22.4691%; background-color: #e0efd4; background: #e0efd4;">Create a record of the specified module</td><td style="width: 22.0988%; background-color: #e0efd4; background: #e0efd4;">elementType (String)element (Encoded)</td><td style="width: 31.1111%; background-color: #e0efd4; background: #e0efd4;">Return all fields and values of the created record</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #e0efd4; background: #e0efd4;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/create

**Parameters**:   
{"elementType":"Accounts", "element":"{\\"accountname\\":\\"account1\\", \\"assigned\_user\_id\\":\\"19x1\\"}"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%;">**update**</td><td style="width: 22.4691%;">Update the specified record</td><td style="width: 22.0988%;">id (String)columns (Encoded)</td><td style="width: 31.1111%;">Return all fields and values of the updated record</td></tr><tr><td colspan="3" style="width: 75.679%;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/update

**Parameters**:   
{"id":"3x310", "columns":"{\\"accountname\\":\\"test fede postman\\"}"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #e0efd4; background: #e0efd4;">**revise**</td><td style="width: 22.4691%; background-color: #e0efd4; background: #e0efd4;">Update the specified record. It’s different only for parameters, the result is the same</td><td style="width: 22.0988%; background-color: #e0efd4; background: #e0efd4;">element (Encoded)</td><td style="width: 31.1111%; background-color: #e0efd4; background: #e0efd4;">Return all fields and updated values</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #e0efd4; background: #e0efd4;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/revise

**Parameters**:

{"element":"{\\"id\\":\\"3x27\\",\\"employees\\":\\"5\\",\\"industry\\":\\"Banking\\"}"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #ffffff; background: #ffffff;">**retrieve**</td><td style="width: 22.4691%; background-color: #ffffff; background: #ffffff;">Illustrate the fields of the specified record and their relative values</td><td style="width: 22.0988%; background-color: #ffffff; background: #ffffff;">id (String)</td><td style="width: 31.1111%; background-color: #ffffff; background: #ffffff;">Return all fields and values of the specified record</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #ffffff; background: #ffffff;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/retrieve

**Parameters**:   
{"id":"3x310"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #e0efd4; background: #e0efd4;">**retrieveinventory**</td><td style="width: 22.4691%; background-color: #e0efd4; background: #e0efd4;">Illustrate the fields of the specified inventory record, their relative values and the product block’s information</td><td style="width: 22.0988%; background-color: #e0efd4; background: #e0efd4;">id (String)</td><td style="width: 31.1111%; background-color: #e0efd4; background: #e0efd4;">Return all fields and values of the specified record and product’s block information</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #e0efd4; background: #e0efd4;">Ex:

**Url**: VTE\_URL/restapi/v1/vtews/retrieveinventory

**Parameters**:

{"id":"16x104"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #ffffff; background: #ffffff;">**delete**</td><td style="width: 22.4691%; background-color: #ffffff; background: #ffffff;">Delete the specified record</td><td style="width: 22.0988%; background-color: #ffffff; background: #ffffff;">id (String)</td><td style="width: 31.1111%; background-color: #ffffff; background: #ffffff;">Return the request status (successful or not)</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #ffffff; background: #ffffff;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/delete

**Parameters**:   
{"id":"3x306"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #e0efd4; background: #e0efd4;">**query**</td><td style="width: 22.4691%; background-color: #e0efd4; background: #e0efd4;">Execute a query and return the result’s rows</td><td style="width: 22.0988%; background-color: #e0efd4; background: #e0efd4;">query (String)</td><td style="width: 31.1111%; background-color: #e0efd4; background: #e0efd4;">Return all rows of the executed query</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #e0efd4; background: #e0efd4;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/query

**Parameters**:

{"query":"SELECT \* FROM Accounts WHERE accountname like '%vte%';"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #ffffff; background: #ffffff;">**listtypes**</td><td style="width: 22.4691%; background-color: #ffffff; background: #ffffff;">Describe each one module which contains uitype of the specified format</td><td style="width: 22.0988%; background-color: #ffffff; background: #ffffff;">fieldTypeList (Encoded)</td><td style="width: 31.1111%; background-color: #ffffff; background: #ffffff;">Return module information of the specified fieldtypes</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #ffffff; background: #ffffff;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/listtypes

**Parameters**:

{"fieldTypeList":"\[\\"integer\\",\\"file\\"\]"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #e0efd4; background: #e0efd4;">**describe**</td><td style="width: 22.4691%; background-color: #e0efd4; background: #e0efd4;">Describe the specified module and their relative fields</td><td style="width: 22.0988%; background-color: #e0efd4; background: #e0efd4;">elementType (String)</td><td style="width: 31.1111%; background-color: #e0efd4; background: #e0efd4;">Return all module information and its fields properties(no hidden fields)</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #e0efd4; background: #e0efd4;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/describe

**Parameters**:

{"elementType":"Accounts"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #ffffff; background: #ffffff;">**describeall**</td><td style="width: 22.4691%; background-color: #ffffff; background: #ffffff;">The describeall method is different from describe one because it shows hidden fields too</td><td style="width: 22.0988%; background-color: #ffffff; background: #ffffff;">ElementType (Encoded)</td><td style="width: 31.1111%; background-color: #ffffff; background: #ffffff;">Return all module information and its fields properties(hidden fields too)</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #ffffff; background: #ffffff;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/describeall

**Parameters**:

{"elementType":"Accounts"}

</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #e0efd4; background: #e0efd4;">**getlabels**</td><td style="width: 22.4691%; background-color: #e0efd4; background: #e0efd4;">Return all labels and translated ones of the specified module,language</td><td style="width: 22.0988%; background-color: #e0efd4; background: #e0efd4;">username (String)language (String)module (String)</td><td style="width: 31.1111%; background-color: #e0efd4; background: #e0efd4;">Return labels and translated ones of the specified module, language</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #e0efd4; background: #e0efd4;">Ex:**Url**: VTE\_URL/restapi/v1/vtews/getlabels

**Parameters**:

{"username":"admin", "language":"it\_it", "module":"Accounts"}

</td></tr><tr><td style="width: 24.1975%; background-color: #ffffff; background: #ffffff;">**getlangs**</td><td style="width: 22.4691%; background-color: #ffffff; background: #ffffff;">Return all languages installed into the CRM</td><td style="width: 22.0988%; background-color: #ffffff; background: #ffffff;"> </td><td style="width: 31.1111%; background-color: #ffffff; background: #ffffff;">Return all CRM languages</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #e0efd4; background: #e0efd4;">**loginpwd**</td><td style="width: 22.4691%; background-color: #e0efd4; background: #e0efd4;">Return user webservice access key if username and password are valid</td><td style="width: 22.0988%; background-color: #e0efd4; background: #e0efd4;">username (String)password (String)</td><td style="width: 31.1111%; background-color: #e0efd4; background: #e0efd4;">Return user webservice access key</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #e0efd4; background: #e0efd4;">Ex:**Url**: VTE\_URL/restapi/v1/vtews/loginpwd

**Parameters**:

{"username":"admin","password":"123456789"}

</td></tr><tr><td style="width: 24.1975%; background-color: #ffffff; background: #ffffff;">**getmenulist**</td><td style="width: 22.4691%; background-color: #ffffff; background: #ffffff;">Return all modules information (visibility, tabid, name, sequence, ...)</td><td style="width: 22.0988%; background-color: #ffffff; background: #ffffff;"> </td><td style="width: 31.1111%; background-color: #ffffff; background: #ffffff;">Return modules information and properties</td></tr><tr><td rowspan="2" style="width: 24.1975%; background-color: #e0efd4; background: #e0efd4;">**oldoquery**</td><td style="width: 22.4691%; background-color: #e0efd4; background: #e0efd4;">Return records that contain the searched value into specified module’s fields</td><td style="width: 22.0988%; background-color: #e0efd4; background: #e0efd4;">module (String)search\_fields (Encoded)search\_value (String)</td><td style="width: 31.1111%; background-color: #e0efd4; background: #e0efd4;">Return some record basic information where searched value is contained into the specified module’s fields</td></tr><tr><td colspan="3" style="width: 75.679%; background-color: #e0efd4; background: #e0efd4;">Ex: **Url**: VTE\_URL/restapi/v1/vtews/oldoquery

**Parameters**:

{"module":"Accounts", "search\_fields":"\[\\"accountname\\", \\"website\\"\]", "search\_value":"vtenext"}

</td></tr></tbody></table>

</div>Technical documentation for SDK is available [here](https://usermanual.vtenext.com/books/developers/page/rest-webservice-methods).