1s post request does not save data. Searching for an object by search fields

1s post request does not save data. Searching for an object by search fields

When developing the procedure for sending information to the site from 1C with platform version 8.3.9.2170, I ran into a problem: the site developer gave me the opportunity to record the necessary information only using an HTTP request using the PUT method.

Without thinking twice, I sketched a simple code:

Connection = New HTTPConnection("www.mysite.ru"); Headers = New Match; Headers["Content-Type"] = "application/x-www-form-urlencoded"; Request = New HTTPRequest("/api/order_items/93076?order_item=30", Headers); Connection.Write(Request);

Based on the results of the execution, the corresponding line of the buyer's order on the website should have indicated the quantity of goods received at the warehouse.

However, as you probably already understood, nothing happened. After I made sure that there were no errors on the site (by sending a similar request through the Chrome plugin), I ran on my local computer web server and began to experiment.

A strange thing immediately came to light: the above code generates not a PUT, but a HEAD request!

In the Apache logs I saw the following:

127.0.0.1 - - "HEAD /api/order_items/93076?order_item=30 HTTP/1.1"

I was a little surprised (after all, it was written in black and white in the manual PUT), but I was not at a loss - after all, you can call the method directly:

Connection.CallHTTPMethod("PUT",Request);

The logs are the same:

127.0.0.1 - - "HEAD /api/order_items/93076?order_item=30 HTTP/1.1"

"Maybe I'm doing something wrong?" - I asked myself a question. But on the Internet and in the manuals there were no clues. Well, no one has yet canceled the method of scientific poke. To start, I tried to do this:

Connection.CallHTTPMethod("fwfw", Request);

In the logs I got:

127.0.0.1 - - "?????? /api/order_items/93076?order_item=30 HTTP/1.1"

Curiously, it means that 1C specifically replaces the PUT method (why did he not please 1C?).

After a few more tries, I came up with this:

Connection.CallHTTPMethod("PUT", Request);

In the logs I got:

127.0.0.1 - - "PUT /api/order_items/93076?order_item=30 HTTP/1.1"

And this option has already worked on the site and everyone was satisfied.

He suggested a more correct solution to the problem: you must specify the request body, any, even empty. For example, this would work:

Connection = New HTTPConnection("www.mysite.ru"); Headers = New Match; Headers["Content-Type"] = "application/x-www-form-urlencoded"; Request = New HTTPRequest("/api/order_items/93076?order_item=30", Headers); Query.SetBodyFromString("", TextEncoding.UTF8, UseByteOrderMark.Don't Use); Connection.Write(Request);

And it is already quite correct, probably, to transfer the parameter values ​​themselves in the request body.

The conclusion is as follows: the 1C platform considers a PUT request without a body to be erroneous and replaces the method with HEAD.

It is curious that 1C does not track a POST request without a body and does not turn it into GET, it was checked for the sake of sporting interest.

As the well-known Vovochka from the famous joke would say: "Where is the logic?".

I hope my publication will save someone a few hours of life in search of an answer. =)))

When developing the procedure for sending information to the site from 1C with platform version 8.3.9.2170, I ran into a problem: the site developer gave me the opportunity to record the necessary information only using an HTTP request using the PUT method.

Without thinking twice, I sketched a simple code:

Connection = New HTTPConnection("www.mysite.ru"); Headers = New Match; Headers["Content-Type"] = "application/x-www-form-urlencoded"; Request = New HTTPRequest("/api/order_items/93076?order_item=30", Headers); Connection.Write(Request);

Based on the results of the execution, the corresponding line of the buyer's order on the website should have indicated the quantity of goods received at the warehouse.

However, as you probably already understood, nothing happened. After I made sure that there were no errors on the site (by sending a similar request through the Chrome plugin), I launched a web server on my local computer and began to experiment.

A strange thing immediately came to light: the above code generates not a PUT, but a HEAD request!

In the Apache logs I saw the following:

127.0.0.1 - - "HEAD /api/order_items/93076?order_item=30 HTTP/1.1"

I was a little surprised (after all, it was written in black and white in the manual PUT), but I was not at a loss - after all, you can call the method directly:

Connection.CallHTTPMethod("PUT",Request);

The logs are the same:

127.0.0.1 - - "HEAD /api/order_items/93076?order_item=30 HTTP/1.1"

"Maybe I'm doing something wrong?" - I asked myself a question. But on the Internet and in the manuals there were no clues. Well, no one has yet canceled the method of scientific poke. To start, I tried to do this:

Connection.CallHTTPMethod("fwfw", Request);

In the logs I got:

127.0.0.1 - - "?????? /api/order_items/93076?order_item=30 HTTP/1.1"

Curiously, it means that 1C specifically replaces the PUT method (why did he not please 1C?).

After a few more tries, I came up with this:

Connection.CallHTTPMethod("PUT", Request);

In the logs I got:

127.0.0.1 - - "PUT /api/order_items/93076?order_item=30 HTTP/1.1"

And this option has already worked on the site and everyone was satisfied.

He suggested a more correct solution to the problem: you must specify the request body, any, even empty. For example, this would work:

Connection = New HTTPConnection("www.mysite.ru"); Headers = New Match; Headers["Content-Type"] = "application/x-www-form-urlencoded"; Request = New HTTPRequest("/api/order_items/93076?order_item=30", Headers); Query.SetBodyFromString("", TextEncoding.UTF8, UseByteOrderMark.Don't Use); Connection.Write(Request);

And it is already quite correct, probably, to transfer the parameter values ​​themselves in the request body.

The conclusion is as follows: the 1C platform considers a PUT request without a body to be erroneous and replaces the method with HEAD.

It is curious that 1C does not track a POST request without a body and does not turn it into GET, it was checked for the sake of sporting interest.

As the well-known Vovochka from the famous joke would say: "Where is the logic?".

I hope my publication will save someone a few hours of life in search of an answer. =)))

The task arose of transferring data between 1C (development and configuration was outsourced), which is planned to be used as the main electronic document management system (EDM) and a B2B system (internal development), which is written in PHP (Symfony) and performs the functions of primary information entry into companies.

I already had experience integrating B2B with another B2B. The bottom line was to transfer JSON using cURL. Then the task of integrating the Borlas system based on Oracle arose, where this approach was also applied. On the Oracle side, however, they used their own package - an analogue of cURL in PHP (if it's interesting, I can describe it in a new article).

As I found out, 1C 8.2 can also send GET and POST requests. I assumed that if everything is already set up and working with other systems, then it should work here too. JSON was rejected by 1C developers, saying that the format is not suitable and they only recognize XML. Comments that this would give us a minimum size when transferring data, and there really was a lot of data, were rejected. As a result, we started preparing 2 systems based on XML.

For my part, I wrote a request acceptor from 1C and return the results. A function for receiving a variable in POST, in which 1Sniki had to substitute XML.
The format is something like this:

123ABC456//authorization key get_last_orders// operation they want to perform 4000//limit of records that they want to select

A handler that returns records already selected according to the conditions and generates XML of the form:

1 OPS 4853352 01.01.2013 1 Loaded from b2b SNILS 999999999 Full name of the client MIKHAILOV MIKHAIL EVGENIEVICH Application date 01.01.2013 ...

Data can only be transferred over an HTTPS connection.

At first glance, it seems that everything is simple, but several problems arose in the process:
1) outsourcers reported that they were unfamiliar with requests of this kind, and tried to offer an old proven scheme:
1. file import from B2B,
2. Loading in 1C,
3. Exporting a file indicating what they were able to process, what was not from 1C,
4. Import to B2B,
5. and from the very beginning…
The scheme was rejected, as it was necessary quickly, and without human intervention and any "buttons".

Then they asked for a code example. On the Internet, I "googled" the following example:

Server = "test.com"; Port = "443"; HTTP Attempt = New HTTPConnection(Server, Port, True); Else HTTP = New HTTPConnection(Server, Port); EndIf; ScriptAddress = "/gateway/GetData1C/"; Attempt HTTP.SendToProcess(SendFileName, ScriptAddress, ResponseFileName, HTTP Header); Exception Report("Unsuccessful connection attempt: " + ErrorDescription()); ElseLoginLogWrite("HTTPConnection",LogLogLevel.Error, "Unsuccessful connection attempt: " + ErrorDescription()); EndIf Return; End of Attempt;

Data began to come to the server, but empty, that is, GET and POST were empty. I added an entry to the logs and successfully forgot about it. After 4 months, I was given an urgent task - to bring the integration to a result (since a lot of time has passed, the 1C developers are working, working, but nothing comes in response). I was given 1C and I started to "poking around".

First, I decided to put Fiddler in order to understand what was happening. I noticed that the connection goes via HTTP, and then the server redirects to HTTPS. I assumed that for this reason the data is empty. I tried to reproduce in Chrome, and received confirmation that the data in the POST request is lost during the redirect.

Since it is impossible to allow work via HTTP, I began to study why, because it is indicated that:

HTTP = New HTTPConnection(Server, Port, True); The "True" parameter means to use HTTPS, and then it dawned that HTTP = New HTTPConnection(Server, Port);

As a result, this "Otherwise" was thrown out, and received an error that invalid certificate. The certificate was self-signed. Integration development was carried out on internal servers, where the officially purchased certificate was from Thawte SSL CA, in contrast to the PROD server. Importing the certificate to all possible stores did not lead to a result.

The search for resources has led to the fact that 1C has its own root certificates, and based on them, it already checks the rest. They lie in a test form in the "cacert.pem" file, which is located in the "bin" folder, where 1C is located. Import is not as simple as it turned out.

First we need to export the certificate we need to a file (I already had it in my personal storage). By running "certmgr.msc", finding the certificate, we export it to the *.cer file.

C:\OpenSSL-Win64\bin>openssl x509 -inform der -in C:\fiddler.cer -out C:\fiddler.pem -text -fingerprint -md5 WARNING: can"t open config file: /usr/local/ ssl/openssl.cnf MD5 Fingerprint=13:BF:73:43:BB:69:19:BA:22:5D:C7:2E:44:85:91:7F
We save MD5, we will need it.
Next, open the file "cacert.pem".
We go down to the very bottom and add first MD5, and then all the contents that turned out in the fiddler.pem file.
We save the file.
We restart 1C (maybe not necessary, but it didn’t work for me, so I restarted everything.

The source file in 1C was given in the following form:

Procedure SendRequestClick(Element) Connection = GetHTTPConnection(); If Connection = Undefined Then Report("Could not connect to the server specified in the exchange settings! Processing aborted!"); Else Source = FileAddr; EndIf; FileName = FileResult; PostFileName = PostFile; SubmissionFile = New File(PostFileName); SendFileSize = XMLString(SendFile.Size()); Headers = New Match(); Headers.Insert("Content-Type", "application/x-www-form-urlencoded"); Headers.Insert("Content-Lenght", SubmissionFileSize); Attempt Connection.SendForProcessing(PostFileName, Source, FileName, Headers); Exception Report(ErrorDescription()); End Attempt End Procedure Function GetHTTPConnection() Export Attempt Connection = New HTTPConnection(HTTPServer,"443",True); Exception Report(ErrorDescription()); Connection = undefined; End of Attempt; Return Connection; EndFunction Procedure OnOpen() HTTPServer = "test.com"; FileAddress = "/gateway/GetData1C"; PostFile = "C:\POST_1C\post.txt"; FileResult = "C:\POST_1C\result.xml"; EndProcedure

After clicking on the button, a request went over HTTPS and the correct XML was received at the output.

I was looking for how 1C works over HTTPS, a lot of material, but I didn’t find how to work with a self-signed certificate.

Print (Ctrl+P)

The second part can be seen

General information

In platform version 8.3.5.1068 , published in September 2015, a mechanism for integrating 1C with external programs through technology REST interface. The platform uses the OData protocol as the access protocol. It is an open web protocol for querying and updating data. It allows you to manipulate data using HTTP commands as requests. Replies in version 8.3.5.1068 could only be received in the format Atom/XML . However, starting from release 8.3.8.1652 in August 2017, a second option for getting data in JSON format (JavaScript Object Notation) has appeared. . Compared to XML, it is easy for humans to read and takes up less space. In addition, all browsers have built-in tools for working with JSON.

Working with the OData protocol on the 1C: Enterprise platform can be found in the book 1C: Developer's Guide in Chapter 17 Internet Service Mechanisms, paragraph 17.2.1 Standard OData interface. You can also look at examples of extending OData protocol support,

Use advantage REST interface. concludes that in order to gain access to system data from an external application, modification of the application solution code is not required (for example, if the application solution is supported). To gain this access, you must publish the application to the web server in a special way and specify which configuration objects will be used in this way. After that, third-party systems can access your application with using HTTP requests.

The publication of the standard OData interface is performed using the publish dialog on the web server (Administration - Publish to web server) and described in the book 1C: Enterprise 8.3. "Administrator's Guide".
Important! In order for configuration objects to become available through the standard OData interface, you must enable this using the global context method Set Composition of StandardODataInterface().
The mechanism for setting the composition of objects available using the standard OData interface can be done in the form external processing. This does not require modification of the applied solution.

To interact with an external REST web server from 1C:Enterprise, the tools available in the platform for working with HTTP are used: objects HTTPConnection, HTTPRequest and HTTPResponse.

In this series of articles, I will show examples of typical operations using the corresponding HTTP method;

  • Data Acquisition - Method GET;
  • Object Creation - Method POST;
  • Data update: method PATCH- in this case, you can specify only those properties that need to be updated; method PUT– in this case, it is necessary to specify all the properties of the entity;
  • Deleting data - method DELETE.

1. Examples of data acquisition. HTTP method GET

The server will be a database published on the web server with the name webbuh(Demo-base “Accounting of the Enterprise 3.0”). I will use the JSON format as the data exchange format. More information about working with JSON is written in the documentation available. To receive data from the server using the GET HTTP method, you need to create an object Reading JSON to sequentially read JSON data from a file or string. To organize sequential recording of objects and texts on the server using the POST PATCH PUT HTTP method, you need to create an object JSON entry. Note that the DELETE method does not require JSON.

As an illustration of streaming reading and writing JSON when accessing the REST interface, I will call the following general purpose custom function CallHTTPMethodOnServer :

&On server // <Описание функции>// // Options: // - A string containing the name of the HTTP method for the request ("POST"."PATCH", "PUT" ,"GET","DELETE" // - HTTPConnection object //<АдресРесурса>- String of the http resource to which the HTTP request will be sent. //<ОтправляемыеДанные>- Structure or correspondence containing the data sent to specified address to be processed // to the server using the specified HTTP method "POST" or "PATCH" or "PUT" // Return value: // Server response structure depending on HTTPMethod// Function CallHTTPMethodOnServer(HTTPMethod,HTTPConnection,ResourceAddress,SubmittedData = Undefined ) // Create an HTTP Request headers = new match(); Headings.Insert("Content-Type", "application/json"); HTTP Request = New HTTP Request ( ResourceAddress, Headers ); // Writing a Json to create and update data If HTTPMethod="POST" or HTTPMethod="PATCH" or HTTPMethod="PUT" Then JSONWriter = NewJSONWriter ; JSON Parameters = New ParametersJSON entries(Wrap JSON.Auto,"",True ); JSON Write.SetString(Parameters JSON ); WriteJSON(WriteJSON, SentData ); // SentData required in this case StringForBody = WriteJSON.Close(); RequestHTTP.SetBodyFromString(StringForBody , EncodingText.UTF8, Using ByteOrderMark.Don't Use); EndIf; // Call HTTPConnection Method ResponseHTTP = HTTPConnection.CallHTTPMethod(HTTPMethod, HTTP Request) ; Response Structure= New Structure ; Response Structure.Insert ("StatusCode ", HTTP Response.StatusCode); // Read JSON for GET method only If HTTPMethod="GET" Then Attempted Reading JSON = New Reading JSON ; Server Response = ResponseHTTP.GetBodyAsString("UTF-8"); ReadJSON.SetString(ServerResponse); Match = ReadJSON(ReadingJSON,True ); Response Structure.Insert("Server Response",Correspondence) ; Response Structure.Insert (" Server ResponseUndecrypted", ServerResponse ); Exception Report(Error Description()); Return Undefined; End of Attempt; end if; Return Response Structure ; EndFunctions // Call HTTPMethodOnServer()

To receive from the server in JSON format, when accessing the REST interface of the application, you need to specify in the resource address $format=json. Or specify MIME type application/json in the title:

headers = new match(); Headers.Insert("Content-Type", "application/json") ; ResourceAddress =" webbuh/odata/standard.odata/ ?$format=json" HTTP Request = New HTTPRequest(ResourceAddress, Headers);

Global context feature ReadJSON(ReadJSON, True )

  • If the value of the second parameter is set to True , reading the object JSON will be done in Correspondence.If set to False , objects will be read into an object of type Structure.
  • When deserializing JSON objects into a struct, be aware of the struct key requirements. If the deserialization of an object finds a property name that is not valid for a structure key, an exception will be thrown.

1. 1 Configuring HTTP connection parameters

To organize the client part of interaction with an external REST web server, I created a client configuration based on BSP from scratch. On this configuration, I created a directory for setting connection parameters (see Fig. 1)

Fig 1 Reference manual for configuring HTTP connection parameters to external IB through the rest interface

After pressing the button Check server response a procedure is called by which the client will try to receive the server's response. The program code for the procedure is written below:

&OnClient Procedure CheckConnection(Command) Address = Object.ServerAddress; User = Object.User; Password = Object.Password; BaseName = Object.Name; Port = ? (Object.Port<>0,Object.Port,80); HTTPConnection = New HTTPConnection(Address, Port, User, Password); ResourceAddress = BaseName + "/odata/standard.odata/ $metadata "; //Calling a custom function Response Structure= B callHTTPMethodOnServer("GET", HTTPConnection,ResourceAddress) ; If Response Structure <> Undefined Then General PurposeClientServer.InformUser("Status Code "+Response Structure.StatusCode); end if; EndProcedure

The purpose of this procedure is service check and whether the user entered the connection parameters correctly. To do this, just make a GET request:
HTTPConnection.CallHTTPMethod( "GET", RequestHTTP) ;
using resource address:
Resource Address =BaseName+ /odata/standard.odata/ “;
You can also check the operation of the service in the browser using
URL
http://host/WebBuh/odata/standard.odata. As a result of such a query, only a list of entities is obtained. For getting complete description standard interface OData (list of available entities, their attributes and functions in the form of XML-
document.) you need to make a GET request using the parameter $metadata. URL http://host/WebBuh/odata/standard.odata/$metadata. Detailed description The document is available at http://www.odata.org/documentation/ (in English).
You can receive answers in the format Atom/XML or JSON. HTTP response status codes can be viewed Responses in the ranges:

  • 100-199 – informational responses indicating that the client's request has been accepted and is being processed.
  • 200-299 – means that the client's request was processed successfully.
  • 300-399 means that the request failed and the client needs to take some action to satisfy the request.
  • 400-499 - informs about errors on the side of the client application. These codes may also indicate that additional information is required from the client.
  • 500-599 - Informs about an error on the server side, indicates that the server has encountered an error and will probably not be able to fulfill the client's request.

1.2 Searching for an object by ID

The following function is designed to search for a directory or document by a unique identifier on the server. If the object is found, then the function returns the string value of the identifier (Ref_Key) , otherwise it returns undefined. The following parameters are passed to the function:

  • HTTPConnection – Object of type HTTPConnection
  • PublishName - The name of the published server database
  • Element - entity identifier of the object, for example, Catalog_Organizations or Document_ - directory of the Organization.
  • Identifier - The identifier of the object to be looked up on the server, for example, Organization.UniqueIdentifier()
&AtServer Function SearchObjectBy GUID (HTTPConnection,PublicationName,Element,UniqueIdentifier) GUID = String(Unique Identifier); // convert to a string ResourceAddress = + Element+ "(guid""+ GUID+ "")?$format=json" ; Response Structure = BcallHTTPMethodOnServer("GET" , HTTPConnection,ResourceAddress) ; If Response Structure .StatusCode >= 400 Then //General PurposeClientServer.NotifyUser(Element+ "Error"+ResponseStructure.StatusCode+ //General PurposeClientServer.NotifyUser(ResponseStructure.ServerResponseUndecoded); return undefined; EndIf ; Match = Response Structure. ResponseServer a; Array = Match["value"]; If Array = Undefined Then Return Match ["Ref_Key"] Else Return Array ["Ref_Key"]; EndIf; EndFunctions

Parameter Resource Address is used to access the REST service. To check the operation of the service, you can specify the resource in the browser in this way

http://(WebServerAddress)/(PubName)/odata/standard.odata/(Item)?(Parameters) ,Where

  • WebServer Address– The address of the web server where the service is published, for example Localhost
  • NamePublications- Name information base specified at the time of publication of the decision
  • /odata/standard.odata/ – Sign of access to the standard OData interface
  • Element – resource identifier or predefined resources. For example, Catalog_Account(guid'value').
  • Options– resource parameters. Used, for example, for selection, in the accepted for HTTP requests: ?key=value&key2=value2

1.3 Searching for an object by search fields

The following user-defined function is designed to search for an object by search fields in the case when the object is by identification number. Function object string Ref_Key-an identification number.

&AtServer Function P searchObjectBySearchFields(HTTPConnection,PublicationName, Element,SearchFields) Condition = "" ; For Each Key Value From Search Field Loop Condition = Condition + KeyValue.Key+"eq""+ KeyValue.Value+ "" and "; EndCycle; RequestText =Lion(Condition, StrLength(Condition)-5); // remove the last 5 characters Resource Address= PublicationName+ "/odata/standard.odata/" +Element+ "?$filter=" + RequestText+ "&$format=json& $select=Ref_Key" ; // Call my custom function Response Structure= callHTTPMethodOnServer( "GET",HTTPConnection,ResourceAddress); If Response Structure .StatusCode >= 400 Then //General PurposeClientServer.InformUser(Element+ "Error"+Response Structure.StatusCode); //General PurposeClientServer.NotifyUser(ResponseStructure.ServerResponseUndecrypted); return undefined; EndIf; Match = Response Structure. ResponseServer a; Array = Match["value" ]; If Array = Undefined Then Return Match ["Ref_Key" ] Otherwise Return Array ["Ref_Key" ]; EndIf; EndFunctions

As seen from the body of the procedure P SearchObjectByFieldsSearch, selection starts with keyword$filterin the resource address. Formal parameterSearch fields -this is a correspondence that contains the names and values ​​of the attributes.

Note that the name of the details is sometimes not obvious. It must be remembered that for directories:

  • code - code,
  • Description
  • DeletionMark - deletion mark,
  • IsFolder - a sign of a group,
  • Parent_Key is the parent.
  • If the attribute is of a reference type, add the _Key suffix to its name, for example, Contractor_Key.

For documents:

  • Number – document number,
  • Date - date of the document.

Logical selection operations

  • eq - Equal to; /Catalog_Cities?$filter=Name eq ‘Main’;
  • ne - Not equal; /Catalog_Cities?$filter=Name ne ‘Perm’;
  • gt - more; /Catalog_Products?$filter= Price gt 10;
  • ge - Greater than or equal to; /Catalog_Products?$filter=Price ge 10;
  • lt - less; /Catalog_Products?$filter=Price lt 10;
  • le - Less than or equal to; /Catalog_Products?$filter=Price le 10;
  • or - Logical OR; /Catalog_ Products ?$filter= Price lt 10 or Price gt 100;
  • and - Logical AND; / Catalog _Products?$ filter =Price g t 10 and Price l t 100;
  • not - Negation; /Catalog_ Products ?$filter=not (Price eq 10);

Note also that the value of the actual parameter Element(or entity)) which I pass to the function formed according to the following rule:

PrefixName_ConfigurationObjectName_SuffixName.

Using the standard OData interface, you can access following objects (Name Prefix):

  • Directory - Catalog;
  • Document - Document;
  • Document Journal - DocumentJournal;
  • Constant - Constant;
  • Exchange plan - ExchangePlan;
  • Chart of accounts - ChartOfAccounts
  • Calculation type plan - ChartOfCalculationTypes;
  • Chart of types of characteristics - ChartOfCharacteristicTypes;
  • Information register - InformationRegister;
  • Accumulation Register - AccumulationRegister;
  • Calculation Register - CalculationRegister;
  • Accounting register - AccountingRegister;
  • Business process - BusinessProcess;
  • Task - Task.

ConfigurationObjectName- property "Name" of the configuration object as it is set in the configurator.

Name suffix- needed to specify the resource name, optional, can take the following values:

  • The name of the tabular part of the object;
  • Name virtual table object;
  • RowType - row of the tabular part of the object;
  • RecordType is a single register entry.

Resource Access Options

After forming the resource name, you need to define the parameters for accessing the resource, for example, ?$filter= Meaning &$format=json& $select= Ref_Key ,

  • $filter- selection when receiving data
  • $format- specifies the format of the returned data,
  • $select- enumeration of entity properties that will be included in the query result;
  • $metadata- returns a description of the standard OData interface (used without specifying a name suffix, an example is in one of the images above);
  • $top- limiting the number of returned records;
  • $skip- removes the specified number of records from the query result;
  • $count- returns the number of records in the query selection;
  • $inlinecount=allpage(=none)- adds information about the number of records to the query result
  • $orderby=<Реквизит1>asc,<Реквизит2>desc- sort query result
  • allowOnly- only allowed (used without the "$" sign).

1.4 Get an array of information register entries

Let's look at an example of obtaining an array of records of the register of information on the full name of individuals, for example, the history of changing the full name individual

NamePublications ="WebBuh"; Element = "InformationRegister_Name of Individuals"; Period = Undefined ; ReferenceType Data= New Struct(); D DataReferenceType.Insert("PhysicalPerson",PhysicalPerson_Key); DataNonReferenceType= New Struct(); DataNonReferenceType.Insert("PhysicalPerson_Type", "StandardODATA.Catalog_PhysicalPersons") Array = GetRegisterRecordSetDetails(HTTPConnection, PublicationName, Item, Period, DimensionsReferenceType, Measurements of Non-ReferenceType)

The body of the function GetRegisterRecordSet, which is called in this example, is shown below.

&AtServer Function GetRegisterRecordSetDetails(HTTPConnection , Publication Name , Item , Period = Undefined , DimensionsReferenceType= Undefined , Measurements of Non-ReferenceType= undefined ) RequestText ="" ; If Period<>Undefined Then FormattedPeriod= Format(Period ,"DF=yyyy-MM-ddTHH:mm:ss"); QueryText = "Period = datetime""+ FormattedPeriod + """ ; EndIf; If DimensionsReferenceType <>Undefined Then For Each KeyValue Of DimensionsReferenceType Cycle Compressed = ? ( ValueFilled(QueryText ), "," ,""); QueryText = QueryText+ Powered + KeyValue.Key+ "=guid(""+ KeyValue.Value+ "")"; EndCycle; EndIf; If Measurements of Non-ReferenceType<> Undefined Then For Each KeyValue Of Measurements of Non-ReferenceType Cycle Asking = ? ( ValueFilled(QueryText ), "," ,""); QueryText = QueryText + Query+ K keyValue.Key + "=" + KeyValue.Value; EndCycle; EndIf; ResourceAddress = PublicationName + " /odata/standard.odata/" + Element + "("+ QueryText + + ") ?$format=json"; // Call my custom function Response Structure = CallHTTPMethodOnServer("GET",HTTPConnection,ResourceAddress); If Response Structure.StatusCode >= 400 Then//General PurposeClientServer.InformUser(Element+ "Error"+Response Structure.StatusCode); //General PurposeClientServer.NotifyUser(ResponseStructure.ServerResponseUndecrypted); return undefined; EndIf; Match = 0