Posting a file to a chat

Last updated: 2020-10-08 Contributors Byrne Reese
Edit this page

An important part of communication within the context of collaboration is the sharing of files and images with teammates. Sharing and displaying an image or a file is done by posting the file's contents to a designated endpoint. The code below shows how to post a file to a chat, assuming you already know the chat ID.

        function(resp) {
        var endpoint = "/restapi/v1.0/glip/files"
            bindata = fs.readFileSync('./cats.png');
   endpoint, bindata, {
                name: "cats.png", groupId: '367050754'
                .then( function(resp) {
                    var json = resp.json()
                    file_id = json[0]['id']
                    console.log( "Uploaded file. File ID: " + file_id )

This simple script will result in a file being uploaded, and a message being posted to the associated team. It will appear as follows:

Uploading a File

To upload a file, one conducts an HTTP POST to the following URI, using the file's contents as the post body. Developers must be sure to set the content-type properly. They should also post the following parameters in the query string:

Parameter Description
name The name of the file.
groupId The RingCentral chat in which to post this file.

Sample Request

POST /restapi/v1.0/glip/files?name="My file"&groupId=101500
Content-Type: audio/wav
Accept: application/json
Authorization: Bearer {access_token}

/// Binary content

The response will include the file's ID and the URL at which the file can be accessed.

Sample Response

        "id": "100500",
        "contentUri": "",
        "name": "My_music"

See Also

Rate this page: