Now the platform can automatically generate REST interface for entire application solution. You publish it in the usual way on the web-server and after that the third-party systems may access your application using HTTP requests.
REST interface allows reading the data of 1С:Enterprise, change them, create new objects and delete the existing ones.
You can use REST interface for such tasks as:
- Integration of application solution with web sites and online shops;
- Implementation of additional functionality for application solution using third-party tools without changing its configuration;
- Loading data in the application solution and uploading data from it;
- integration of application solution with corporate systems, probably even without additional programming.
typical operations performed using REST interface are as follows:
- Obtaining the list of documents, catalogs, information register records, etc., possibly with filter;
- obtaining data of the items of catalog, document (by reference), record data of independent information register (by key), record set data of subordinate register (by recorder);
- Data editing of a single item of catalog, document and another reference object;
- Creating new item of catalog, document, record set;
- Conducting a single document, running business-process.
As an access protocol the platform uses the protocol OData release 3.0. This is an opened web-protocol to request and update data. It allows manipulating with data using the HTTP-commands as the requests. It is possible to get the responds in various formats, but we support as yet only the work with data in Atom/XML format.
We have implemented in the platform only the server part of REST services. That is, the application solution can automatically deliver its functionality using REST services. To interact with the third-party REST services from 1С:Enterprise (to organize the client part), it is possible to use the tools existing in the platform to work with HTTP: objects HTTPConnection, HTTPRequest and HTTPRespond.
However, the main task of REST interface for application solutions we see in the integration with third-party systems. And here there is no problem, because the OData clients exist almost for all major platforms:
It is easy to use OData interface of application solution:
- In the Designer you publish REST interface - the flag Publish standard interface OData;
- After that, the objects of application solution become available through this interface;
- The authentication methods of OData clients are identical to the methods use for web-services;
- OData clients may request via HTTP the metadata document which describes available application solution objects;
- OData clients performs the operations to create, read, modify and delete data of application solution.
Almost all the major configuration objects are available in the REST interface: catalogs, documents, constants, enumerations, exchange plans, accumulation registers, calculation, accounting and information registers, virtual tables of periodical information register, accounting and accumulation registers, charts of accounts, characteristic types and calculation types, business-processes, tasks and document journals.
Unavailable at the moment are the reports and data processors, commands, selection filters, scheduled jobs, external data sources and users.
In the REST interface the attributes of configuration objects, operations to create, read, modify and delete data are available, as well as some script methods. For example:
- For document - Post() and Unpost();
- For task - ExecuteTask();
- For business-process - Start();
- For information register - SliceLast() and SliceFirst();
- For accumulation and accounting register - Balance(), Turnovers() and BalanceAndTurnovers();
- For calculation register - ScheduleData(), ActualActionPeriod(), <RecalculationName>() and Base<Name of base calculation register>().
Data reading is performed using GET-request. For example, reading the catalog list Goods (hereinafter only the request headers are listed for short):
For example, data reading of a single item of catalog Goods by GUID:
Creation of a new data item is performed using POST-request. As a value of reference a null GUID is passed. When creating and modifying the objects, the values of properties are passed in the request body in XML format (here the request text is listed in full):
POST /OData_Tests_Infobase/odata/standard.odata/Catalog_Goods HTTP/1.1 Content-Type: application/atom+xml DataServiceVersion: 3.0;NetFx MaxDataServiceVersion: 3.0;NetFx Accept: application/atom+xml,application/xml Accept-Charset: UTF-8 User-Agent: 1C-Enterprise Host: test-host:8090 Content-Length: 1610
false T-shirt blue false 00000000-0000-0000-0000-000000000000 F400322D-7AE8-4803-A7BE-0D80E525E8C2
Modification of existing data is performed using PATCH-request. For example, data modification of a single item of catalog Goods by GUID:
To delete data, DELETE-request is used (mark for deletion will be implemented in future in a separated ODATA-operation):
Methods of script objects are executed using POST-requests. For example, document conduction:
In case of an error situation, 1С:Enterprise returns a response with HTTP-status 4XX or 5XX. 4XX status tells about incorrect client actions, 5XX status – about an error on the server. in case of 4XX status, 1С:Enterprise tries to help the client to understand the reason of an error and can send an additional internal error code and information message.
When reading and writing data using REST interface, the platform performs all the usual security checks and call the event handlers, except the filling check.
When working through the REST interface, an optimistic data lock is supported. When requesting data (of a single object or a list) together with them the platform returns the values of field (fields) DataVersion. In the subsequent requests PUT, PATCH и DELETE with the same data it is possible to send to 1С:Enterprise the version of read data. If the version of data existing in the information base did not change by this moment, the requested action is performed.
When receiving the data lists, it is possible to use the standard conditions for filtering ODATA requests. For example, receive the goods whose price is lower or equal to 3,5 or more than 200:
GET /OData_Tests_Infobase/odata/standard.odata/Catalog_Goods?$filter=Price le 3.5 or Price gt 200
Thanks to the versatility and cross-platform property, we position the automatically generated REST interface as a basic tool for integration with third-party systems.