C
C
Chingar0502021-04-28 10:01:40
1C
Chingar050, 2021-04-28 10:01:40

How to download a file from the Bitrix24 infoblock in 1C?

There is a link of this kind https://domain/bizproc/processes/147/file/0/67609/P...
There is such a code for 1C.
Connection = New HTTPConnection("Domain",,"Login","Password",,5,New SecureConnectionOpenSSL());
Request = New HTTPRequest("sofi-soft.bitrix24.ru/bizproc/processes/147/file/0/"+String(StrTab.DOCUMENT_ID)+"/PROPERTY_727/"+String(StrTab.UploadFile)+"/?ncc =n&download=n");
Response = Connection.Get(Request);
If Response.StatusCode = 302 Then
ResourceAddress = Response.Headers.Get("Location");

Request = New HTTPRequest(ResourceAddress);
Response = Connection.Get(Request);
BinaryDataPictures = Answer.GetBodyAsBinaryData();
BinaryDataPictures = Answer.GetBodyAsBinaryData();
EndIf; BinaryDataPictures.Write("\\storage\Share\DOCUMENTS_ACCOMPANYING\"+String(StrTab.DOCUMENT_ID)+".jpg");

Initial response Status code 302. At 302, I send the address from the Header to the jump. Location. Still getting 302 code. And so in a circle. The output is an empty file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2021-06-11
@gromdron

Plug in Fiddler and see which request really leaves.
I am not a 1C specialist, but I don’t see that you specify port 443 (judging by the documentation and examples from 1C sites) as the second parameter when opening an HTTP connection

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question