V
V
Vyacheslav Ovchinnikov2015-11-12 09:53:35
1C
Vyacheslav Ovchinnikov, 2015-11-12 09:53:35

How to send/teach a file via OData REST API 1C?

I work with REST API OData in 1C. There are no problems with creating/getting objects.
But I ran into a problem when adding / receiving files through this interface.
I create an object in "Catalog_ContractsContractorsAttachedFiles" - the object is created without problems.
If you look in $metadata, the object has the following parameters:

...
<Property Name="Расширение" Type="Edm.String" Nullable="true" />
<Property Name="ТекстХранилище_Base64Data" Type="Edm.Binary" Nullable="true" />
<Property Name="ФайлХранилище_Base64Data" Type="Edm.Binary" Nullable="true" />
<Property Name="ТекстХранилище" Type="Edm.Stream" Nullable="true" />
<Property Name="ФайлХранилище" Type="Edm.Stream" Nullable="true" />
...

So, as far as I understand, the contents of the file must be sent through these parameters.
I tried to pass the contents of the file in each of these parameters and in base64 and just - nothing happens.
In 1C, the file is displayed in the attached files of the agreement, but when you try to open it, it gives an error that "The file was not found in the file storage."
Also, it is not possible to get the contents of the file (created in the same directory via 1C) via REST.
Tried to query:
Catalog_ContractsAccountsAttachedFiles(guid'GUID')/TextStorage
Catalog_AgreementsAccountsAttachedFiles(guid'GUID')/FileStorage Returns
nothing.
Maybe someone worked with files through OData, and, in particular, with REST API 1C, tell me how to do this?
upd
Figured out how to add/get a file via OData.
When creating an entry in the directory, in the "FileStorage_Type" parameter, specify the mime-type of the file (for example, image/jpeg), in "FileStorage_Base64Data" we shove the contents of the file encoded in base64.
After that, you can get the file via OData in two ways:
1. .../Catalog_AccountsAgreementsAttachedFiles(guid'GUID')/FileStorage - returns the file itself
2. .../Catalog_AgreementsAccountsAttachedFiles(guid'GUID')/FileStorage_Base64Data/$value - returns the contents file encoded in base64
But!At the same time, this file still does not open through 1C, and gives the same error, as well as files added through 1C cannot be obtained through OData - in "FileStorage_Base64Data" it is simply empty!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Ovchinnikov, 2015-11-16
@ova777

They helped with the solution of the issue at Infostart.
For those who are interested, see here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question