Views: 495 (Data available since 06.02.2017)

The method publishes loaded file in the chat

Revision: 18
Get information on the current API revision (platform version) – im.revision.get.

Parameters

Parameter Example Req. Description Revision
CHAT_ID 17 Yes Chat ID 18
UPLOAD_ID 213 Yes* ID of the file, downloaded via DISK module methods 18
DISK_ID 112 Yes* ID of the file, available from the local drive 18
MESSAGE Important document No File description will be published in chat 18
SILENT_MODE N No Open Channel chat parameter that specifies if the file data was sent to a client or to another designation 18
  • To call the API successfully, specify CHAT_ID and one за two fields – UPLOAD_ID or DISK_ID.

Attention! File must be preliminarily downloaded via the disk.folder.uploadfile method.


Method call

JavaScript

BX24.callMethod('im.disk.file.commit', {
	'CHAT_ID': 17,
	'UPLOAD_ID': 112,
}, function(result){
	if(result.error())
	{
		console.error(result.error().ex);
	}
	else
	{
		console.log(result.data());
	}
});

PHP

$result = restCommand('im.disk.file.commit', Array(
	'CHAT_ID' => 17,
	'UPLOAD_ID' => 112,
), $_REQUEST["auth"]);

Example of response

{
	"result": true
} 

Example of response when error occurs

{
    "error": "CHAT_ID_EMPTY",
    "error_description": "Chat ID can't be empty"
}

Description of keys:

  • error – error code
  • error_description – brief description of error

Possible error codes

Code Description
CHAT_ID_EMPTY Chat ID not passed
ACCESS_ERROR Current user does not have permissions to access the dialog
FILES_ERROR File ID not passed

Attention! The method is specified with using of the restCommand function. This method is used to send data in Bitrix24 and is available in the EchoBot example as well as in this article. You can use your own function or BX24.callMethod, or bitrix24-php-sdk JavaScript methods.





Courses developed by «Bitrix», Inc.