Automatic REST interface for applied solutions

Now the platform can mechanically generate a REST interface for the complete software resolution. You publish it on an internet server within the traditional means, after which third-party programs can enter your software utilizing HTTP requests.

The REST interface lets you learn 1C: Enterprise information, modify it, create new objects, and delete present ones.

It would help if you used the REST interface for duties akin to:

  • Integration of the utilized resolution with Web websites and online shops;
  • Implementation by the third-party technique of extra performance of the utilized resolution without altering its configuration;
  • Loading information into a utilized resolution and unloading information from it;
  • Integration of the applying resolution with company programs, presumably even without extra programming.

Typical operations carried out by the REST interface are:

  • Acquiring a listing of paperwork, directories, data register data, and so forth., presumably with a filter;
  • Acquiring information of a listing aspect, doc (by reference), news of an unbiased register of knowledge (by key), word of a set of data of a subordinate record (by a registrar);
  • Modifying information of 1 aspect of the reference e-book, doc and one other reference object;
  • Creation of a brand new aspect of the listing, doc, set of data;
  • Finishing up one doc, beginning an enterprise course of.

The platform uses the protocol as an entry protocol Once time model 3.0. It’s an open internet protocol for querying and updating information. It lets you manipulate information utilizing HTTP instructions as requests. Solutions may be acquired in numerous codecs; however, for now, we solely assist in working with details in Atom / XML format.

We have now carried out solely the server aspect of REST companies within the platform. That’s, a utilized resolution can mechanically ship its performance through REST companies. To work together with third-party REST companies from 1C: Enterprise (for organizing the consumer aspect), you should utilize the instruments obtainable within the platform for working with HTTP: HTTPConnection, HTTPRequest and HTTPResponse objects.

Nevertheless, we see the primary job of the REST interface for utilized options in integration with third-party programs. And right here, the issue doesn’t come up, as a result of OData shoppers existing for nearly all critical platforms:

It’s easy to make use of the standard OData interface of the utilized resolution:

  • Within the configurator, you publish the REST interface – the Publish customary OData interface test field;
  • After that, the objects of the operated key grow to be obtainable by this interface;
  • The authentication strategies for OData shoppers are precisely identical to these used for internet companies;
  • OData shoppers can request by HTTP a metadata doc describing the obtainable objects of the applying resolution;
  • OData shoppers carry out making, studying, modifying and deleting software information.

Virtually all primary configuration objects can be found within the REST interface: directories, paperwork, constants, enumerations, alternate plans, accumulation registers, calculation, accounting and knowledge, digital tables of the periodic data register, accounting registers and accumulation registers, charts of accounts, attribute sorts and calculation sorts, enterprise processes, duties and doc journals.

At the moment, not obtainable are reviews and processing, instructions, choice standards, scheduled duties, exterior information sources and customers.

Within the REST interface, the requisites of configuration objects can be found, operations for creating, studying, modifying and deleting information can be found, in addition to some strategies of the embedded language. For example:

  • For a doc – Submit () and Unpost ();
  • For a job – ExecuteTask ();
  • For an enterprise course of – Begin ();
  • For data register – SliceLast () and SliceFirst ();
  • For the buildup register and accounting register – Steadiness (), Turnovers () and BalanceAndTurnovers ();
  • For the calculation register – ScheduleData (), ActualActionPeriod (), () and Base ().

Studying information is completed with a GET request. For instance, learning the record of the Items listing (from now on, for brevity, solely request headers are given):

GET /OData_Tests_Infobase/odata/customary.odata/Catalog_Goods

For instance, studying the info of 1 merchandise of the Items catalogue by GUID:

GET /OData_Tests_Infobase/odata/customary.odata/Catalog_Goods(guid'7f4b5034-0331-11e3-b914-5404a6a68c42')

The creation of brand new merchandise is completed with a POST request. A null GUID is handed because of the reference worth. When creating and modifying objects, property values ​​are passed within the request physique in XML format (right here, the textual request content is given in total):

POST  /OData_Tests_Infobase/odata/customary.odata/Catalog_Goods HTTP/1.1
Content material-Kind: software/atom+xml
DataServiceVersion: 3.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Settle for: software/atom+xml,software/xml
Settle for-Charset: UTF-8
Person-Agent: 1C-Enterprise
Host: test-host:8090
Content material-Size: 1610

<?xml  model="1.0" encoding="utf-8"?>
<entry  xmlns=http://www.w3.org/2005/Atom  
        xmlns:d=http://schemas.microsoft.com/ado/2007/08/dataservices  
        xmlns:m=http://schemas.microsoft.com/ado/2007/08/dataservices/metadata  
        xmlns:georss=http://www.georss.org/georss  
        xmlns:gml=http://www.opengis.internet/gml>

   <class time period="EnterpriseV8.CatalogGoods"  scheme=http://schemas.microsoft.com/ado/2007/08/dataservices/scheme />
   <id />
   <title />
   <up to date>2013-08-12T11:48:25Z</up to date>
   <creator>
      <title />
   </creator>
   <content material sort="software/xml">
      <m:properties>
         <d:Code>157</d:Code>
         <d:DeletionMark>false</d:DeletionMark>
         <d:Description>Майка синяя</d:Description>
         <d:IsFolder>false</d:IsFolder>
         <d:Parent_Key m:null="true" />
         <d:Ref_Key m:sort="Edm.Guid">00000000-0000-0000-0000-000000000000</d:Ref_Key>
         <d:Артикул m:null="true" />
         <d:Поставщик_Key>F400322D-7AE8-4803-A7BE-0D80E525E8C2</d:Поставщик_Key>
      </m:properties>
   </content material>
</entry>

Modification of present information is completed with a PATCH request. For instance, altering the info of 1 merchandise within the Items catalogue by GUID:

PATCH /OData_Tests_Infobase/odata/customary.odata/Catalog_Goods(guid'7f4b5034-0331-11e3-b914-5404a6a68c42')

To delete information, a DELETE request is used (marking for the deletion shall be carried out sooner or later as a separate ODATA operation):

DELETE /OData_Tests_Infobase/odata/customary.odata/Catalog_Goods(guid'7f4b5034-0331-11e3-b914-5404a6a68c42')

POST requests execute embedded language object strategies. For instance, posting a doc:

POST /OData_Tests_Infobase/odata/customary.odata/Document_Invoice(guid'17ed2041-0345-11e3-b914-5404a6a68c42')/Submit()

In an error scenario, 1C: Enterprise returns a response with HTTP standing 4XX or 5XX. The 4XX standing signifies the inappropriate actions of the consumer; the 5XX standing signifies an error on the server. Within the case of the 4XX 1C: Enterprise standing, the corporate tries to assist the consumer in perceiving the reason for the error and ship an extra inner error code and informational message.

When studying and writing information utilizing the REST interface, the framework performs all the standard permissions checks and invokes occasion handlers, excluding padding checks.

Optimistic information locking is supported when working by the REST interface. When requesting information (one object or a listing) together, the framework returns the worth of the DataVersion subject (s). In subsequent PUT, PATCH, and DELETE requests with identical information, you may ship 1C: Enterprise, the model of the learned information. If the model of the info within the Infobase has not been modified by this time, the requested motion is carried out.

When retrieving knowledge lists, you should utilize normal ODATA question filtering circumstances. For instance, to get items for which the value is lower than or equal to three.5 or greater than 200:

GET /OData_Tests_Infobase/odata/customary.odata/Catalog_Goods?$filter=Value le 3.5 or Value gt 200

Because of its versatility and cross-platform nature, we place the mechanically generated REST interface as the primary instrument for integration with third-party programs. Subsequently, growth and assist web extensions we plan to cease.

Tags: OData 8.3.5

Inform mates:

Facebook
Twitter
Pinterest
WhatsApp

Related Articles

Latest Articles