Syntax and Examples
Note:This chapter is about the now obsolete version 1.0 of Vine REST. Please do not use REST 1.0 for new projects and consider updating your existing code to Vine REST 2.0 as soon as possible since support for REST 1.0 will be discontinued in the future.
Vine REST interface to the Vine database is integrated into Vine Web. It is used, for example, by Vine Sales Meeting Tool.
Sample of a request:
http://vineyard:8080/vineyard/rest/v1.2/vy_person(300001061)/objectimage
- get the photo of the person with given id in binary format
Syntax:
base_url / resource [(value_conditions)]
[/link] [(value_conditions)]
[/field]
[?params]
base_url – base URL of the service, for example:
Example:
http://vineyard:8080/vineyard/rest/v1.1
Note: v1.1 – is the REST version here. It is always recommended to use the latest version of REST available. Currently the latest version is v1.2. So the base_url part could be, for example:
http://vineyard:8080/vineyard/rest/v1.2
- requests with such base_url will be using the v1.2 version of REST
http://vineyard:8080/vineyard/rest/v1
- requests with such base_url will be using the v1 version of REST
resource - name of the table (VY_PERSON, VY_COMPANY, ...) or name of a special virtual resource - USER – current logged in user.
Example:
http://vineyard:8080/vineyard/rest/v1.2/vy_resource([status]='B')
returns all fields (except special) of all not deleted rows using vy_resource_view
value_conditions = id|{field_condition|link_condition}[{and|or}field_condition|link_condition]
- id - object identifier
- field_condition = field_name { = | < | > |<= | >= | in } { value | expression }
- link_condition = special syntax to check object connection $[connectionTypeId:connectedObjectId]. One of parameters should be provided.
where
where field_name – [name of the field], value - constant value, expression - any expression supported by XMLQuery
If connectionTypeId skipped it means any connection type.
Instead of connectedObjectId the following syntax can be used to get the id of the current user: [$user]
Note: Using the special syntax of link_condition is not recommended and its support may be discontinued. We recommend using the FilterConnection function.
Examples:
http://vineyard/vineyard/rest/v1.1/VY_EVENT(300166001)
- get event with specified ID. returns all fields except special ones
Please note that REST does not filter out deleted rows in Vine (rows with Status='D'). You need to add the [status]='D' condition yourself if you do not want to receive deleted rows. Status check is automatically added only in connections ( VY_PERSON/1) and in queries by ID: VY_PERSON(12345). For connections only connection status is checked.
/vineyard/rest/v1.1/VY_COMPANY([businessid]='1234567-1' and [status]='B')
- get single company using the businessid field
/vineyard/rest/v1.1/VY_EVENT(([startdate] > MakeDate(GetYear([$now]), GetMonth([$now]), 1) and [enddate] > ([$now]+14)) AND [status]='B')
-returns events which happen in two weeks time from now
/vineyard/rest/v1.1/vy_company(($[1:[$user]] OR $[1:300110962]) and [status]='B')
returns companies which are employers of the current user or of a person with id=300110962
http://vineyard/vineyard/rest/v1.1/VY_CONNECTION([fromobjectid]=101002212 and [connectiontype]=11 and [targetobjectid]=107000441 and [status]='B')
Checks if company belongs to collection.
link = [+|-] (link1_id, link2_id,...linkN_id) [( value_condition )] [ /link ]
where link_id - link identifier.
Direction of link is determined automatically by object type if it's possible ("from" and "target" object types differ). Else it should be set explicitly by [+|-].
Number of links can be unlimited.
Please note that when multiple link_id used
Examples:
/vineyard/rest/v1.1/VY_EVENT(300166001)/4
- get person responsible( connection id = 4) for given event.
/vineyard/rest/v1.1/user/4
get events for which the current user is responsible
/vineyard/rest/v1.1/USER/1/16($[:[$user]])
- gets employer for the current user and then events connected at the same time to the employer (contype=16) and to the current user with any connectiontype (contype skipped).
/vineyard/rest/v1.1/USER/3([startdate]>([$now]-14))/4
- get events started no more than 14 days ago and connected to the user as attendee and then get persons responsible for these events
/vineyard/rest/v1.1/USER/3,4([startdate]>([$now]-14))
- get events connected to the user as attendee or responsible and then choose ones which started no more than 14 days ago
field - returned field.
- returns always "binary file" = "application/octet-stream", does not respect the type requests (e.g.the XML or JSON request types)
- can fetch only one field (requests like "person/name,lastname" are not allowed)
- usually used to get binary data from the database and should be used only in special cases when, for example, downloading binary data.
- returns only the first entity from the matched set.
At least 2 tables have additional 'virtual' ID fields. For example, there are no columns named 'id' in VY_USERSETTING, VY_DOCUMENTVERSION, and VY_SYNCACCOUNT. The service uses other columns as ID column for these tables as follows: SETTINGID for vy_usersetting, DOCUMENTID for VY_DOCUMENTVERSION, and ACCOUNTID for VY_SYNCACCOUNT.
Examples:
/vineyard/rest/v1.1/VY_EVENTTYPE(-2)/NAME
- gets the name of VY_EVENTTYPE item with id=-2
Tables not linked with VY_CONNECTION table (for example, parameter tables) are not included in the main hierarchy but can be queried individually.
/vineyard/rest/v1.1/VY_PERSON(300001061)/OBJECTIMAGE
- get the photo of the person with given id in binary format
params – regular sequence of parameters from the following supported ones:
- skip - number of skipped rows
- top - number of returned rows
- order - sorting order. "asc" - ascending(default), "desc" - descending
- showspecial - show special fields (blobs and xml fields), note that by default special fields are not returned. base64 encoding used for binary data when showspecial is used.
- $count - this parameter forces the query to return the size of the data selection instead of the data itself
- idField - used for tables which do not have an ID field. REST assumes that there is an ID field in a database query result
Examples:
/vineyard/rest/v1.1/vy_company?skip=20&top=10&order=name asc
-the resulting sequence first sorted by name, then 20 rows are skipped and 10 companies starting from 21st are returned
https://devmyvine.intra/vineyard/rest/v1.1/vy_table_field?idField=OOFID
- this query will fail without idField
Comments
0 comments
Please sign in to leave a comment.